server side search and filtering

server side search and filtering

aniljanilj Posts: 6Questions: 0Answers: 0
edited March 2014 in DataTables 1.10
I am using the DataTable() API with a serverSide set to true with an ajax() call. I have a search box that I want use to filter the data on the server side. I am able to submit the request and the server returns back the table (with the specific rows filtered out).

However, my table doesn't get redraw with the data removed/filtered.
I do this to search and redraw the table:
[code]
searchTable.columns( colIdx ).search( fieldvalue ).draw();
[/code]

The server returns a JSON with the filtered data, but the table still shows *all* the data even with the draw.

Should I be using search().draw() or do I need to go through each of the rows and in JS remove the rows using rows().remove()?

Thanks!

Replies

  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin
    As long as your server-side processing script is doing the required filtering, that looks like it should work to me. Can you link me to the page so I can take a look?

    Allan
  • jrichviewjrichview Posts: 36Questions: 7Answers: 0
    edited March 2014
    I'm facing a similar problem. Love DataTables and currently using it in a POC written with MVC.

    Today I realized that in addition to searching displayed grid columns our search needs to perform a fulltext search in an enterprise document management system. Somehow I need to merge in results of that search into the datatables search. Or maybe we'll just do our own search.

    This also means that search as you type won't be a viable approach. We'll have to add a "Search" button next to the search field, etc.

    Any guidance you could offer would be most appreciated.
  • aniljanilj Posts: 6Questions: 0Answers: 0
    I figured it out. I was not returning the *same* draw integer that was being requested through the ajax call. I had originally copied it from the example and had it hard coded to 1, maybe a little warning or comment in the example to remind people?

    Thanks Allan for the support!
  • jolyon2000jolyon2000 Posts: 12Questions: 0Answers: 0
    What do you specify if you don't want to search on a specific column and just needs some extra parameters sending to the server processing script?
  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin
    Use fnServerParams in 1.9 and ajax.data in 1.10: http://next.datatables.net/reference/option/ajax

    Allan
This discussion has been closed.