Table calls sortInternalRows with externalSorting=true
See original GitHub issueI’m submitting a … (check one with “x”)
[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter
Current behavior
When externalSorting
is enabled, the sortInternalRows()
method is still called due to this commit: https://github.com/swimlane/ngx-datatable/commit/67a4e8aeaf6c03e7fa3bc6a6d0a34725ec1c6b0a This causes the rows to change their sort order in undesirable ways after they are passed to the datatable component. Single sorting seems to work fine, but when combined with [sortType]="'multi'"
the sort order is incorrect.
I believe the additional call to sortInternalRows()
added to the translateColumns()
method should be changed to:
if (!this.externalSorting) {
this.sortInternalRows();
}
Expected behavior
Multi sorting would work correctly with externalSorting=true
and the grid would never attempt to sort the rows itself.
Reproduction of the problem
Turn on [externalSorting]="true"
and [sortType]="'multi'"
and see that the sortInternalRows()
method is called.
Please tell us about your environment:
- Table version: 11.3.0
- Angular version: 5.2.4
- Browser: Chrome 67.0.3396.99
- Language: TypeScript 2.5.3
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5
Top GitHub Comments
As nobody from the ngx-datatable seems to answer this issue, I downgraded the package to 11.2.0. However, I quickly discovered that this creates another bug in my app. The fix for it was merged in 13.0.1: https://github.com/swimlane/ngx-datatable/pull/1375
Moreover, in our case the sorting issue exists even with
[sortType]
set to'single'
.Therefore, I came up with the workaround - define a Noop comparator like so:
This looks bad, but fixes the issue, allowing us to use the latest version. We can remove rxjs-compat now by the way. 👍
I hope this helps @dmartinzar @ronsc @lecongbang90!
This issue also affects
[sorts]
input. For example if you are sorting a table from outside and then want to apply correct view state to column header.[externalSorting]="true" [sorts]="externalSort$ | async"
will cause client side sorting.