Jump to page based on search (with bServerSide)

Jump to page based on search (with bServerSide)

fbasfbas Posts: 1,094Questions: 4Answers: 0
edited November 2011 in DataTables 1.8
Here's a little twist on searching that I'd like to implement. (with bServerSide)

Client wants to be able to jump to page based on some criteria. To keep it simple, perhaps I'd only allow the jump based on row id.

Would like to send all the same search criteria to back-end (the jump-to search would not replace or interfere with the global filter but instead should complement it) but rather than return a paginated selection, calculate which page it would be on and return that number.

Is there an easy way to gather all the same info that would be passed as aoData when a draw/filter is called on server-side scripts?

[my specific case involves using sColumns and array-based, sName (not mDataProp) based inputs, but a general solution to fit all cases would be best]

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    I guess the hackish way I'll do this is:

    1) set a jump-to value
    2) in fnServerData detect jump-to value and add a parameter to aoData, clear the client-side jump-to value
    3) if json returns with jump-to page specified, go to that page, else process with fnCallback
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    I think your suggestion in your follow up post is probably the best way of doing this. Since you are using server-side processing, its basically down to the server to figure out what needs to be displayed - so it must tell the client-side what data is to be shown. The difficulty is in telling the table that the data it is now showing is in fact page 3, rather than page 1 (or whatever).

    So two possibilities spring to mind:

    1. You could implement caching of the JSON response (a bit like the server-side cache example) to reduce the XHRs required for each draw to just 1 (i.e. always return the data set you want to draw, but you your flag as well - then if the flag is set on the redraw, no request will be required - just give it the data from before).

    2. Similar to 1, but slightly backwards, when you see your flag, have the table redraw, but use the data from the response to draw the table (actually, this could be the same as 1, just depending on how it is implemented!).

    Regards,
    Allan
This discussion has been closed.