tabulator icon indicating copy to clipboard operation
tabulator copied to clipboard

Changing the filter or sorting, while pagination is enabled, does not revert the table back to the first page

Open KarmaProd opened this issue 4 years ago • 8 comments

Describe the bug When using pagination, after changing a filter or sorting, the tabulator page is not restored to first one. Please note that documentation states otherwise, and this behaviour was working in a previous version.

Tabulator Info 5.1.7

Working Example example of bug: http://tabulator.info/docs/5.1/page example of working version: http://tabulator.info/docs/4.1/page

To Reproduce A step by step guide to recreate the issue:

  1. Go to http://tabulator.info/docs/5.1/page and move to the very first table (Overview)
  2. Click on button "2" on the bottom right to move to page two.
  3. Click on Rating in header to sort by rating
  4. Page is not restored to the first one.

Expected behavior Page should be restored to page 1, as the documentation clearly states shortly after in that same page: Note: Changing the filter, sorting or toggling a groups visibility, while pagination is enabled will revert the table back to the first page.

Desktop:

  • OS: Windows 10
  • Browser: Google Chrome
  • Version: 99.0.4844.74

KarmaProd avatar Mar 21 '22 11:03 KarmaProd

Compare #3676 these changes .. I am assuming that it might cause problem in other Modules as well

doublehrajput avatar Mar 25 '22 04:03 doublehrajput

@doublehrajput Unfortunately those changes will result in a reset in horizontal scroll position, which is undesirable when not in paginated mode.

olifolkerd avatar Mar 25 '22 06:03 olifolkerd

Hey @KarmaProd

Thanks for point out the inconsistency here. As much as this is a regression against the previous version. i think it actually highlights a bigger problem with the current design paradigm.

At the moment scroll positions are preserved when a sort occurs (on local data) but not pagination. which is making the same action trigger different actions per module.

To make things more consistent i will make some improvements in the next update. all modules will maintain their current state on sort/filter and then i will add a sortPositionReset and filterPositionReset (or similar) setup option to allow control over whether this resets the table or not.

Cheers

Oli :)

olifolkerd avatar Mar 25 '22 07:03 olifolkerd

Actually, I didn't mention something else I noticed. In my stable installation I use tabulator 5.0.7, and this bug is NOT present. But in the http://tabulator.info/docs/5.0/page documentation page the bug IS present. @olifolkerd do you know why?

KarmaProd avatar Mar 25 '22 14:03 KarmaProd

Because that uses local pagination not remote pagination, the issue isnt about pagination as such but the data source. a remote data source will result in data being reloaded a local source will result in it being refreshed

olifolkerd avatar Mar 25 '22 16:03 olifolkerd

I am upgrading to 5.2.4. Any update about this small bug?

By now, I am applying this workaround:

treegrid.on("tableBuilt", function(){
    // Don't reset page on initial rendering
    treegrid.on("dataSorted", function(sorters, rows){
        treegrid.setPage(1);
    });
    treegrid.on("dataFiltered", function(filters, rows){
        treegrid.setPage(1);
    });
});

KarmaProd avatar May 23 '22 14:05 KarmaProd

I had to do the same as @KarmaProd for workaround. I am using 5.4.

It still shows in its docs: Note: Changing the filter, sorting or toggling a groups visibility, while pagination is enabled will revert the table back to the first page.

mdmangus avatar Feb 07 '23 17:02 mdmangus

@olifolkerd I am using tabulator 5.4 with remote pagination. And i am required to keep the page on filter and sort change. Tabulator5.4 always seems to reset the page back to 1 on filter and sort change. Is there a corresponding option implemented for sortPositionReset and filterPositionReset? Or is there a way to maintain the page?

Thank you in advance for your help.

sinbino avatar Feb 05 '24 03:02 sinbino