How to handle table on search result page with server-side paging

How to handle table on search result page with server-side paging

jlpjlp Posts: 1Questions: 1Answers: 0

I want to use DataTables to display my search results.
However, the table will appear only when user type query and hit search.
Then, all paging and sorting should happen on server.

When should I initialize table? On page load or when search is executed?
How to refresh data when search is hit again?
How to pass total numbers of rows from server response to table?
How to pass page number and page size from table to request, along with search query and criteria (in POST)?

Answers

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

    Hi @jlp ,

    If the server is in charge of ordering and paging, see serverSide for what you need - this page here discusses the protocol for that to happen.

    When you display the table, would be a decision for you, with the flow that best suits your app. What you could do is keep it hidden until the user initiates a search, then make the table visible, with the search string passed in ajax.data (or you could just pass the search into the DataTables search input element).

    Cheers,

    Colin

This discussion has been closed.