sZeroRecords value is displayed before table load
sZeroRecords value is displayed before table load
Hi Allan,
First I wanted to thank you for developing such an amazing product, simply fantastic.
I have one issue, when I have a large server side data load, the table displays 'sZeroRecords' value, for instance 'No records found' before it displays the data. In my case if the user does enters search criteria and submits it, the dataTable function displays an empty table with 'No records found' first and then in about a second loads and displays the data. It only happens the first time the table gets loaded, when I replace the data in the table it work fine.
How can I for instance display 'Processing...' instead of 'No records found' before it displays all the data, because in this case the user gets an impression there is no data and can possibly leave the page before the data loads.
Here is my code:
[code]
oTable = $('#example').dataTable( {
"bProcessing": true,
"sAjaxSource": "http://localhost:7080/WebQueryRelational/json_source.txt",
"bAutoWidth": false,
"oLanguage": {
"sSearch": "Search",
"sZeroRecords": "No records found",
"sProcessing": "Processing..."
},
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": searchData,
"success": fnCallback
} );
}
} );
[/code]
First I wanted to thank you for developing such an amazing product, simply fantastic.
I have one issue, when I have a large server side data load, the table displays 'sZeroRecords' value, for instance 'No records found' before it displays the data. In my case if the user does enters search criteria and submits it, the dataTable function displays an empty table with 'No records found' first and then in about a second loads and displays the data. It only happens the first time the table gets loaded, when I replace the data in the table it work fine.
How can I for instance display 'Processing...' instead of 'No records found' before it displays all the data, because in this case the user gets an impression there is no data and can possibly leave the page before the data loads.
Here is my code:
[code]
oTable = $('#example').dataTable( {
"bProcessing": true,
"sAjaxSource": "http://localhost:7080/WebQueryRelational/json_source.txt",
"bAutoWidth": false,
"oLanguage": {
"sSearch": "Search",
"sZeroRecords": "No records found",
"sProcessing": "Processing..."
},
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": searchData,
"success": fnCallback
} );
}
} );
[/code]
This discussion has been closed.
Replies
There are a couple of options:
1. The 'processing' label should be shown during the initialisation, so you could use CSS to have that cover the table
2. Set the sZeroRecords initially to 'Loading results...' - and then in fnInitComplete, set it to be 'No records found' (oSettings.oLanguage.sZeroRecords = ...).
This isn't something I've specifically experimented with myself, as the results sets I tend to work with in server-side processing return quite quickly, but I believe you could achieve something suitable using one of the above - hopefully :-)
Allan
For some reason I see 'processing' label during initialization in Mozilla Firefox but not in IE. Have you had similar issues?
Thank you, Vlad.
In your suggestion #2 you said initialize sZeroRecords in fnInitComplete. I can not find fnInitComplete function in jquery.dataTables.js.