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

hm123hm123 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

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin

    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

  • hm123hm123 Posts: 84Questions: 27Answers: 1

    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.

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    I looked at the page for row().show() and it looked like you missed a draw() :

        table.api().row(this).draw().show().select().draw(false)
    

    With this in, it appears to be working as expected - please see here,

    Colin

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    Answer ✓

    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

Sign In or Register to comment.