searchpanes 2.0.1 bug, where calling .page('next').draw('page') on the table goes past the last page
searchpanes 2.0.1 bug, where calling .page('next').draw('page') on the table goes past the last page
hm123
Posts: 84Questions: 27Answers: 1
As you can see in this example: http://live.datatables.net/jecalaqu/1/edit
If you are on the last page, and you call .page('next').draw('page') on the table, it jumps back to the first page on the table.
However if you use an earlier version of searchpanes, this does not happen. I've included commented out files for an older version to show this.
This question has an accepted answers - jump to answer
Answers
I've just made commits to both DataTables and SearchPanes to resolve this issue. Thanks for letting me know about it.
This really highlights the limitations of the chaining interface. When
.page('next')
results in no action, then really you'd want.draw('page')
not to be called.The issue is that SearchPanes uses the
page
event listener to decide if a draw is the result of paging or not - in this case it kind of is, but it isn't required, and the page internally doesn't trigger, hence the issue. Its really a workaround that I've put in.Allan
I just checked using the nightly files, and I can confirm that .page('next').draw('page') works as it should
However, I tried something else, and noticed that .draw(false) does not work as expected.
In this example: http://live.datatables.net/weputeye/1/edit
While using the latest fixed nightly version of searchpanes, upon searching for a letter, say Z, the table shows rows with that letter (and pagination only shows the filtered number of pages as it should), then upon double clicking a shown row with the mouse, we are taken to the page where that row would have originally been, without the search having changed the pagination. Up to here everything works as it should.
However, double clicking anywhere again reset the page back to page one, this should not happen. And it doesn't if we use the old 1.4.0 file for searchpanes, which I have included commented out.
Note that even without having searched for anything, upon going to another page and then double clicking anywhere will reset the page we are on all the same.
I looked at the page for row().show() and it looked like you missed a
draw()
:With this in, it appears to be working as expected - please see here,
Colin
I can't immediately explain why Colin's example is working to be honest! But it is...
I agree that the double click event handler in your own example shouldn't be resetting the paging when SearchPanes is enabled. It is exactly the same issue as before - the paging detection doesn't get triggered and therefore SearchPanes does a full redraw. Again a limitation in the chaining API.
I'm not yet certain what the correct why to resolve this fully is. Colin's workaround appears to do the trick for now.
Allan