DataTables 1.9.2 refresh table with sort and pagination state intact

DataTables 1.9.2 refresh table with sort and pagination state intact

SerexxSerexx Posts: 1Questions: 0Answers: 0
edited January 2013 in DataTables 1.9
Before I ask anyone to debug my DataTables page I'd like to ask a basic question, based on this basic DT instantiation:

oTable = $('#datatable').dataTable(
{
"sAjaxSource": dataUrl,
"sAjaxDataProp": dataTypeName,
"bAutoWidth": false,
"iDisplayLength": 10,
"bFilter": true,
"bAjaxDataGet": true,
"aaSorting": [[0, 'desc']],
"aoColumnDefs": [ // etc.
]
});

The dataUrl accepts the request and returns JSON data representing the entire data set. The page then loads as expected - it is paginated, 10 per page and sorted descending on column index 0.

Now the fun - my user is on page two of the listing. She changes a value of an item on that page using a separate (jQuery) AJax call.

I therefore now need to refresh the listing, sort it the way it was sorted pre-refresh, and then go to / display the page she was on at the time of the change/refresh.

Pretty basic data-list stuff and I have seen a few posts related to one or two of the three topics (refreshing, sorting and pagination) but not all three and in all cases it seems the solution(s) worked for some and not others. Clearly that has to do with different DataTables versions, different implementation details and so on, but it has left me blurry and 'guessing'.

So, rather than continue to chase this around I'd like to see if there is any agreement as to what I /should/ be trying to make work.

Given the above how is this /supposed/ to be done (with DT 1.9.2) ?

Thanks!

Replies

  • allanallan Posts: 63,389Questions: 1Answers: 10,450 Site admin
    With the fnReloadAjax plug-in, which includes a standing redraw option (keep the pagination): http://datatables.net/plug-ins/api#fnReloadAjax

    Allan
This discussion has been closed.