How to prevent asSorting is null error when no data is present
How to prevent asSorting is null error when no data is present
I am dynamically creating the datatable with information. But there are times when there is no data present so only the table tags are returned.
Example:
Based on info from previous discussions I can set some variables with the following check.
if ($('#tableinfo thread th').length < 1) {
//set variables in datatable
}
Is there a way I can set the datatable so it sees it as zero records (I can use setting already in datatable).
Here is my code for my dataTable (version 174):
$(document).ready(function(){
oTable = $('#tableinfo').dataTable({
"bJQueryUI": false,
"sPaginationType": "full_numbers",
"bPaginate": true,
"bLengthChange": true,
"bFilter": true,
"bInfo": true,
"bAutoWidth": false,
"bStateSave": true,
"bSort": true,
"oLanguage": {
"sSearch": "Filter all records:",
"sZeroRecords": "ZERO records to display",
"sProcessing": "Getting data..."
},
"aoColumnDefs": [
{ "bSortable": false, "aTargets": ["nosort"] }
]
})
})
Any help would be appreciated.
Kev
Example:
Based on info from previous discussions I can set some variables with the following check.
if ($('#tableinfo thread th').length < 1) {
//set variables in datatable
}
Is there a way I can set the datatable so it sees it as zero records (I can use setting already in datatable).
Here is my code for my dataTable (version 174):
$(document).ready(function(){
oTable = $('#tableinfo').dataTable({
"bJQueryUI": false,
"sPaginationType": "full_numbers",
"bPaginate": true,
"bLengthChange": true,
"bFilter": true,
"bInfo": true,
"bAutoWidth": false,
"bStateSave": true,
"bSort": true,
"oLanguage": {
"sSearch": "Filter all records:",
"sZeroRecords": "ZERO records to display",
"sProcessing": "Getting data..."
},
"aoColumnDefs": [
{ "bSortable": false, "aTargets": ["nosort"] }
]
})
})
Any help would be appreciated.
Kev
This discussion has been closed.
Replies
If you have cells in the header and are still getting this error, then please link us to an example showing the problem so we can see what is happening.
Allan
Thanks - Not doing a true dynamic. I am changing based on selections from a drop down. I guess my best bet is to check to see if the thead exists and if it does not - don't initialize the datatable. I did see something about using "aoData":[{}]; but that messed up sorting on all but the first column.
BTW - like your product and left a contribution yesterday.
V/R,
Kev
Thanks very much for the donation - hugely appreciated!
I think that check you suggest sounds like a good way to go. I do plan on making columns dynamic in future, so this will be supported in later DataTables versions (not yet sure if it will make it into 1.10).
Allan