postpone table data population
postpone table data population
I have a table placed on a dialog. At page start-up dialog is hidden. There is a chance user will never open it.
When dialog is shown, it also sets default filter settings, depending on how dialog was opened.
Can I initialize dataTable at the page load, but populate it only when dialog is opened?
When dialog is shown, it also sets default filter settings, depending on how dialog was opened.
Can I initialize dataTable at the page load, but populate it only when dialog is opened?
This discussion has been closed.
Replies
Allan
bServerSide: true,
sAjaxSource: '../../../../Gems.aspx/Get',
fnServerData: getDataTableServerData,
what do you mean by "dont give it any data"?
I want to prevent table from making a request. So ideally I would use an option "bDontGetDataOnInit" and then trigger data update with "fnGetDataNow" - figuratively speaking.
For now my solution is to not call dataTable function until dialog opened first time and use a global flag "is table initialized".
Another solution would be to make use of fnServerData to do something like this:
[code]
$(document).ready(function() {
var flagInit = true;
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "../examples_support/server_processing.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
if ( flagInit ) {
fnCallback({
fnCallback({
"sEcho": 1,
"iTotalRecords": 0,
"iTotalDisplayRecords": 0,
"aaData": []
});
flagInit = false;
});
} else {
aoData.push( { "name": "more_data", "value": "my_value" } );
fnCallback(json);
}
}
} );
} );
[/code]
Allan
fnServerData : noResultDummyFunction
and just set it to the correct value when I'm ready to show the table:
$('#table').dataTable().fnSettings().fnServerData = realDataGettingFunction;
will that work?
The datatables fnServerData callback captures the flag in a closure, but that is not at all accessible from outside the closure, no global flags here at all!
Allan