如何对带有分组的 ngx 数据表应用排序



我在我的角度应用程序中使用了ngx-datatable组件。我使用[groupRowsBy]="'age'"对数据进行了分组。我想将排序应用于分组数据,所以我尝试了

[sorts]="[{ prop: 'age', dir: 'asc' }]"

但这行不通。

<ngx-datatable
#myTable
class='material expandable'
[rows]="rows"
[groupRowsBy]="'age'"
[columnMode]="'force'"
[scrollbarH]="true"
[headerHeight]="50"
[footerHeight]="50"
[rowHeight]="40"
[limit]="4"
[groupExpansionDefault]="false"
[sorts]="[{ prop: 'age', dir: 'asc' }]">

这是测试的链接

https://stackblitz.com/edit/angular-ngx-datatable-row-grouping-and-row-detail?embed=1&file=src/app/app.component.html

这个问题仍未解决。请参阅 https://github.com/swimlane/ngx-datatable/issues/1329。 但是,解决方案可能是手动更改行中的顺序,添加自定义排序方法。 有一个事件排序,所以你可以有像(sort) = "onSort($event)", 在那里,您必须采用列的名称并以您想要的方式对行重新排序。 希望对:)有所帮助

最新更新