【问题标题】:sort number column in ngx-datatable in ascending and descending order. Angular 2/4按升序和降序对 ngx-datatable 中的数字列进行排序。角 2/4
【发布时间】:2018-04-01 01:02:53
【问题描述】:

我需要对 ngx-datatable 中的 ID 号列进行排序。我的表中也有空值,如何按升序获取列并最终获取空值。它从服务器中排序,但是当我尝试排序 desc 并返回到升序时,空值总是排在第一位。然后我需要在升序排序时排在最后。这是我的一些代码

Template

<ngx-datatable-column prop="ID" name="ID">
     <template let-column="column" let-sort="sortFn" ngx-datatable-header-template>
       <span (click)="sort()" class="sort-fullwidth">ID</span>
     </template>
</ngx-datatable-column>

我不知道该排序方法的去向。我尝试了 [sorts]= " [{ prop : 'ID', dir : 'asc' ] ", [comarator] (但不确定我做的是否正确)。

谢谢

【问题讨论】:

    标签: angular ngx-datatable


    【解决方案1】:

    以下链接描述了默认排序,但 ilyaoverflow 是正确的。您需要添加到 HTML 中的唯一行是:
    [sorts]="[{prop: 'approvalStatus', dir: 'asc'}]"
    https://github.com/swimlane/ngx-datatable/blob/master/demo/sorting/sorting-default.component.ts

    【讨论】:

    【解决方案2】:

    它看起来像这样:

    <ngx-datatable class='material' [columns]="columns" [rows]="rows" [columnMode]="'force'" [headerHeight]="50" [footerHeight]="50" [rowHeight]="'auto'" [limit]="100" [sortType]="'multi'" [reorderable]="true" [sorts]="[{prop: 'ID', dir: 'asc'}]">
    

    【讨论】:

    • 您能否提供更详细的答案/解释。见here
    • 不适合我,我也在使用 group by 并且想要对分组进行排序
    猜你喜欢
    • 2016-10-18
    • 2020-11-09
    • 2015-08-30
    • 2020-10-05
    • 1970-01-01
    • 2020-12-10
    • 2022-01-09
    • 1970-01-01
    相关资源
    最近更新 更多