Searching (Filtering) Within a Specific Page

Searching (Filtering) Within a Specific Page

AdAstraAdAstra Posts: 2Questions: 0Answers: 0
edited August 2011 in General
I've created an implementation of server-side paging/sorting that works well for large datasets - it does the slicing of the data in the DAL itself query rather than bringing everything back over the wire. The problem is, datatables will set the page back to 1 when doing a search (because it thinks it's looking at all the data rather than a slice). Is there a good (easy?) way to preserve the current page (in other words, the iDisplayStart) when doing a search?

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Not really, because your search might mean that the page you are on no longer exists in the data set - for example lets say you are on page 9 and you search for "z". If there are only two records which have "z" in it, then there is only 1 page in the table.

    It is possible to do a standing redraw ( http://datatables.net/plug-ins/api#fnStandingRedraw ) the technique for which could be adapted, but I think you might run into a few problems with this approach.

    Allan
  • AdAstraAdAstra Posts: 2Questions: 0Answers: 0
    Good point, I hadn't even considered that. I ended up with a solution where I keep track of how many records to skip on the server side, then preserve that number if the data was filtered so I can show the a subset of the same results on page 1. Thanks for the direction.
This discussion has been closed.