How do I create a button to re-load a table with a (possibly) different Ajax source

How do I create a button to re-load a table with a (possibly) different Ajax source

travelerjjmtravelerjjm Posts: 11Questions: 1Answers: 0
edited July 2014 in DataTables 1.10

Hi. I am new to DataTables. I love the tool and its flexibility. I just purchased.

I have code very similar to that on http://datatables.net/examples/server_side/row_details.html except I'm not doing server-side processing, but I do want the details (sort of like http://datatables.net/examples/api/row_details.html, but I am using a url instead of a text file.) . I want to have a button on the page to make a different Ajax call and reload the table. For instance, I may load with "/getuser/100" and then I want a button (I'll put it in a form, etc.) so then when I click it, the ajax is changed to "/getuser/105" and the table is reloaded.

What do I need to do to change the Ajax and reload? Just to do the reload I've tried variations of '<button type="button" onclick="table.ajax.reload();">Reload</button>' to no avail.

Thanks!

(I did not post a link because the code is virtually identical to the example so I thought reading the nicely formatted sample would be easier.)

Replies

  • travelerjjmtravelerjjm Posts: 11Questions: 1Answers: 0

    I solved this. "reload" is the id of my button. The code is:

    $('#reload').click(function (){
            var path = "/runningdata/";
            var dt=$('#running').DataTable( );
            dt.clear();
            dt.draw();
            dt.ajax.url(path).load();
    
        });
    
This discussion has been closed.