Add an option to stay on the current page when sort is applied
See original GitHub issueI’m submitting a … (check one with “x”)
[ x] bug report => search github for a similar issue or PR before submitting
[ x] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter
Current behavior
Currently DataTableComponent sets offset to 0 in onColumnSort method when sort is applied.
But, it is not really required to do so in this case because the number of rows should not change during sort.
Also, this doesn’t quite work with server side pagination and sorting - the result that is displayed in this case is from page N, but the offset is set to 0 and footer displays incorrect page number as a consequence.
Expected behavior No need to reset offset to 0 when column is sorted. The offset can be reset programmatically if needed. At least add an option NOT to reset offset to 0 when column is sorted.
Reproduction of the problem Try to use server side pagination and sorting at the same time. Navigate to page N and sort a column. In this case the result from page N are displayed but the footer displays page 1 that does not correspond to the actual results returned.
Please tell us about your environment: Mac os X
-
Table version: 0.8.x 9.1.0
-
Angular version: 2.0.x 4.1.0
-
Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ] Chrome
-
Language: [all | TypeScript X.X | ES6/7 | ES5] TypeScript
Issue Analytics
- State:
- Created 6 years ago
- Reactions:14
- Comments:17 (3 by maintainers)
Top GitHub Comments
Any update on this?
I just realized this post is really old, but it is still OPEN, so here it is. I am doing server-side pagination. I am setting these for the table: #fbaSalesTable … [externalPaging]=“true” [count]=“count” [offset]=“pageNumber” [limit]=“10” (sort)=“onSort($event)” [sorts]=“[{prop: ‘purchaseDate’, dir: ‘desc’}]”
I get a reference to the ngx-datatable using @ViewChild annotation. @ViewChild(‘fbaSalesTable’) table: any;
then I use it in my onSort function:
onSort(event) { this.table.offset = this.pageNumber - 1; };
This is working for me. Hope it helps someone.