jump to spec'd page from JSON
jump to spec'd page from JSON

My server side JSON data source is coming along but the search behavior I'm trying to achieve is this:
1) progressively refine the search adding more letters
2) once it's down to a single result, find the page in the larger results set and then return the page with the UI display the page number in the buttons below and clearing the search box
3) this seems to require both server-side and client-side actions
Is there a way to return a piece of data and call something client-side? And then is there a way to tell the UI we're on a specific page without causing a re-fetch?
Is that the best approach for what I'm trying to do?
Implementation so far:
https://www.freecell.net/f/c/dbscores2.html?game=8x3 (select AS column to sort and type ferc into the search box)
Server-side JSON source (with similar calling params):
http://freecell.net/f/fcv2.p?html=0&game=8x3&column=3&search=ferc
These params find a single match and return a page of regular data but I still need to figure out the pagination and clear the search box.
Worst case I can have it return the single page as it does now but any suggestions about how to play into natural behavior of Datatables would be appreciated.
confundido
Answers
To check my understanding - as you filter down the table and get to a single result you what to perform some action (in this case showing some other html)?
Use
draw
to listen for the table updates and usepage.info()
inside it to determine how many records are shown. If its 1 then do whatever is needed.Allan
Is there a cool way for me to pass back some data in the JSON to be interpreted by my draw listener? Like I can add data items in the ajax function, e.g. "game" below:
And thanks for fast response!
Since the data will change per row, just have the extra data in the row's data object. Then you ca use
row().data()
to get the row's data in your draw event listener - e.g.:Allan