Reusing a table with server side processing
Reusing a table with server side processing
I have a table that is populated by server side processing. It also uses the Scroller "plugin". Note: the table is displayed in a JQueryUI dialog.
It works fine the first time I open it. But, if I scroll down a few pages, close the dialog and then re-open, the display is blank. I don't know how to reset the table/scroller so that it redisplays everything.
It works fine the first time I open it. But, if I scroll down a few pages, close the dialog and then re-open, the display is blank. I don't know how to reset the table/scroller so that it redisplays everything.
This discussion has been closed.
Replies
Thanks very much for taking up the DataTables support option! Sorry I didn't get the opportunity to answer your question before.
When you reopen the dialogue box, do you want the table to show the paging information where it was before, or to reset back to zero? Do you have a link to your page that you can give me, otherwise, I'll build a little example of how it much be done with Scroller.
*edit* - a couple of additional questions - what is your data source for the table? Is it server-side processing, or Ajax source or something else? Are there any other options that you've enabled on the table?
Regards,
Allan
I'd like everything reset - it's a new "session" of the dialog with different data, etc.
[quote]what is your data source for the table?[/quote]
Server side ajax
[quote]allan said: Are there any other options that you've enabled on the table?[/quote]
$('#index-query-results-table').dataTable({
"bProcessing": true,
"bServerSide": true,
"bStateSave": false,
"bFilter": false,
"bJQueryUI": true,
"bSort": false,
"sScrollY": "300px",
"sDom": "frtiS",
"bDeferRender": true,
"iDeferLoading": false
});
var settings = $('#index-query-results-table').dataTable().fnSettings();
settings.sAjaxSource = "index/dataTable/" + indexName + "/" + indexHandle;
In that case, what I think the best option would be is to destroy the table rather than trying to reuse the old one (since you would have to reset the sorting, filtering, etc).
This can be done relatively trivially using the "bDestroy" option. So rather than getting the settings object and manipulating that, call a function that will reinitialise your table as a whole. For example:
[code]
function initTable (src) {
$('#index-query-results-table').dataTable({
"bDestroy": true,
"sAjaxSource": src,
"bProcessing": true,
"bServerSide": true,
"bStateSave": false,
"bFilter": false,
"bJQueryUI": true,
"bSort": false,
"sScrollY": "300px",
"sDom": "frtiS",
"bDeferRender": true,
"iDeferLoading": false
});
}
// Then when you want to change the Ajax source and reinitialise the table
initTable( "index/dataTable/" + indexName + "/" + indexHandle );
[/code]
And that, I think, should do the business for you :-)
Regards,
Allan