Filter using datatables instead of GET?
Filter using datatables instead of GET?
So for a number of my pages they have a location, and currently I have a drop down where they select the location, and I reload the page with the extra info in the URL, pass that via GET into session and to the server side.
While this works fine, it does reload the page each time, which can be frustrating.
I am sure I could be doing this via the AJAX call much more efficiently, but I don't know how, so thought I would ask.
Is there a better way of injecting those code into the serverside and having it perform the filter just as it does with the search? Is there examples I could use?
If needed I can link to our test server for an example, but I think the question is simple enough, just I don't know how to do it.
Answers
I tried using this post as help, but the example no longer works.
https://datatables.net/forums/discussion/56356/how-to-pass-value-of-an-html-element-to-ajax-option-during-datatable-initialization
Can you populate a table using Ajax? That would be the first step. The second would then be to pass your filter value using
ajax.data
(as a function).Allan
Yes, the page is already populated via ajax using serverSide processing.
What isn't clear to me is which example I should use.
Order is:
1. Page loaded with data
2. new location selected
3. data should filter or refresh to the new selected location.
I assumed this:
but didn't seem to do anything.
Let me put it into the test side and link an example for you Allan, will update for tomorrow. Thanks
If you are using server-side processing already (
serverSide
) then absolutely - all you need to do is add the data you want to what DataTables is sending to the server:Allan