question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add an option to stay on the current page when sort is applied

See original GitHub issue

I’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:open
  • Created 6 years ago
  • Reactions:14
  • Comments:17 (3 by maintainers)

github_iconTop GitHub Comments

10reactions
ZeevKatzcommented, Dec 18, 2018

Any update on this?

7reactions
tatighmcommented, Jan 29, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there any way to keep current page when sorting jqgrid ...
My jqgrid contains several pages. When I sort any column the page resets to first. (That's right also for filterToolbar i.e. after calling...
Read more >
Sort data in a range or table - Microsoft Support
How to sort and organize your Excel data numerically, alphabetically, by priority or format, by date and time, and more.
Read more >
Sort data in a table - Microsoft Support
Sort the table. Select a cell within the data. Select Home > Sort & Filter. Sort&Filter. Or, select Data > Sort. DATA-Sort&Filter. Select...
Read more >
Video: Sort data in a range or table - Microsoft Support
Click Sort Z to A to perform a descending sort (Z to A or largest number to smallest). Want more? Sort by dates...
Read more >
Should the sort/filter changes throw the focus on first page or ...
Since using a sort or filter of any kind will most likely change the order and the amount of data displayed, the best...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found