Want to reload data in datatable using ajax

Want to reload data in datatable using ajax

gauravf4ugauravf4u Posts: 4Questions: 0Answers: 0
edited June 2012 in DataTables 1.8
Hi,

I am new to datatables and I am trying to reload data from Server using fnreloadAjax.I have multiple filter options and a search button.I am able to get the data populated in data table when the page is loaded first time using an ajax call by making bserverside =true.What I want is whenever I choose the filter options the data table should get populated with the new data by making a server side call using the same url but with different parameter values.

Here is what I have done so far.Is this the right approach followed by me.Is there another way to reload new data by making an ajax call to server using datatable.I read fnDraw is there but dont know how to use it.Any pointers
Using the below approach invoking function fnReloadAjax 3 requests are going to the server and data is not getting updated in datatable.

Replies

  • snarf2larfsnarf2larf Posts: 64Questions: 0Answers: 0
    Just using

    [code]oTable.fnDraw();[/code]

    Works fine for me. In your case it looks like it would be messagesTable.fnDraw();
  • redipsredips Posts: 2Questions: 0Answers: 0
    edited June 2012
    Sorry but I think is more complicated than it is in your answer.
    Please consider my case: I have some filter set (sSearch_6 = "some text to filter", and so on..) and I want reload ALL DATA, so clearing the filters. How I can do? (Filters are set when loading the php page passing to it some parameter in the query string [GET])
    I have a php page as data source, so an Ajax datasource, returning JSON aaData, bServerSide=true, bDestroy=true.
    Do I have to use fnReloadAjax and and clearing the filter inside my fnReloadAjax? And if yes, how I can do? How do I access the GET parameters to be sent and modify them before then?

    Keep in mind that my windows is opened with filter set, but obviously I put a button to "reload all data"
    set as follow:
    [code]
    $("#reloadButtons").on( "click", "#btnReloadAll", function() {
    // ... Do I have to modify get prameters here? (how)?
    // and then call oTable.fnReloadAjax(); ????
    [/code]

    I hope my question is understandable and clear ...
    Thanks in advance.

    P.S.: Jquery ver.: 1.7.2 and DataTables 1.9.2 :)

    EDIT:
    Found the solution using fnFilter or the plugin api fnFilterClear.
    To be honest I didn't resolve with that, as i changed the search_xxx parammeters in the fnServerData, then introducing a js variable set to 1 (reload all) or 0 (filter) I set the serach criteria on the columns or not. I hoe my explanation is clear, if not I can send a PM with some code I used.

    You can close the discussion. Thanks anyway and thanks for DataTables: a great piece of software!
This discussion has been closed.