Datatable 'Showing 1 to NaN of NaN entries (filtered from NaN total entries)' error
Datatable 'Showing 1 to NaN of NaN entries (filtered from NaN total entries)' error
rpandit
Posts: 14Questions: 0Answers: 0
I am getting this error for serverside datatable even though my iTotalRecords and iTotalDisplayRecords count is correct.
Here is the Datatable definition
$('#tblInbox').dataTable({
"bJQueryUI": true,
"bServerSide": true,
"sAjaxSource": "/folder1/folder2/MessagingService.asmx/LoadMessages",
"sAjaxDataProp": "d.aaData",
"oLanguage": {
"sEmptyTable": ""
},
"bLengthChange": true,
"bFilter": true,
"sScrollX": "100%",
"sScrollXInner": "120%",
"sScrollY": "500px",
"bAutoWidth": false,
'aLengthMenu': [[25, 50, 100, 500], [25, 50, 100, 500]],
'sPaginationType': 'full_numbers',
"iDisplayLength": 25,
"aoColumnDefs": [
{ "bSortable": false,
"aTargets": [0],
fnRender: function (object, value) {
var data = {
'SenderId': object.aData.SenderId,
'ID': object.aData.ID
};
return '';
}, "mDataProp": "ID", sWidth: "40px"
},
{ "aTargets": [1], "mDataProp": "SenderId", sWidth: "100px" },
{ "aTargets": [2], "mDataProp": "SubjectLink", sWidth: "200px" },
{ "aTargets": [3], "mDataProp": "Account", sWidth: "66px" },
{ "aTargets": [4], "mDataProp": "ReceivedDateFormatted", sWidth: "66px" }
],
"aaSorting": [[4, "desc"]],
"fnDrawCallback": function (oSettings) {
$("#inbox .ssDataTable").css("visibility", "visible");
$("#inbox .dataTables_scrollHead").css("visibility", "visible");
},
"fnServerData": function (sSource, aoData, fnCallback) {
$.ajax({
"type": "POST",
"dataType": 'json',
"contentType": "application/json; charset=utf-8",
"url": sSource,
"data": "{'sEcho': '" + JSON.stringify(aoData) + "','msgType' : '" + msgType + "'}",
"success": function (result) {
fnCallback(result); // draw the table
},
"error": function (xhr, ajaxOptions, thrownError) {
alert("There was an error loading your message. Please try again later.");
}
});
}
});
JSON:
HTMLOutput: null
__type: "Messaging"
aaData: Array[25]
iTotalDisplayRecords: 48
iTotalRecords: 48
sColumns: null
sEcho: "[{"name":"sEcho","value":1},{"name":"iColumns","value":5},{"name":"sColumns","value":""},{"name":"iDisplayStart","value":0},{"name":"iDisplayLength","value":25},{"name":"mDataProp_0","value":"ID"},{"name":"mDataProp_1","value":"SenderId"},{"name":"mDataProp_2","value":"SubjectLink"},{"name":"mDataProp_3","value":"Account"},{"name":"mDataProp_4","value":"ReceivedDateFormatted"},{"name":"sSearch","value":""},{"name":"bRegex","value":false},{"name":"sSearch_0","value":""},{"name":"bRegex_0","value":false},{"name":"bSearchable_0","value":true},{"name":"sSearch_1","value":""},{"name":"bRegex_1","value":false},{"name":"bSearchable_1","value":true},{"name":"sSearch_2","value":""},{"name":"bRegex_2","value":false},{"name":"bSearchable_2","value":true},{"name":"sSearch_3","value":""},{"name":"bRegex_3","value":false},{"name":"bSearchable_3","value":true},{"name":"sSearch_4","value":""},{"name":"bRegex_4","value":false},{"name":"bSearchable_4","value":true},{"name":"iSortCol_0","value":4},{"name":"sSortDir_0","value":"desc"},{"name":"iSortingCols","value":1},{"name":"bSortable_0","value":false},{"name":"bSortable_1","value":true},{"name":"bSortable_2","value":true},{"name":"bSortable_3","value":true},{"name":"bSortable_4","value":true}]"
oSettings object :
oSettings: Object
_iDisplayEnd: 0
_iDisplayLength: 25
_iDisplayStart: 0
_iRecordsDisplay: NaN
_iRecordsTotal: NaN
Here is the Datatable definition
$('#tblInbox').dataTable({
"bJQueryUI": true,
"bServerSide": true,
"sAjaxSource": "/folder1/folder2/MessagingService.asmx/LoadMessages",
"sAjaxDataProp": "d.aaData",
"oLanguage": {
"sEmptyTable": ""
},
"bLengthChange": true,
"bFilter": true,
"sScrollX": "100%",
"sScrollXInner": "120%",
"sScrollY": "500px",
"bAutoWidth": false,
'aLengthMenu': [[25, 50, 100, 500], [25, 50, 100, 500]],
'sPaginationType': 'full_numbers',
"iDisplayLength": 25,
"aoColumnDefs": [
{ "bSortable": false,
"aTargets": [0],
fnRender: function (object, value) {
var data = {
'SenderId': object.aData.SenderId,
'ID': object.aData.ID
};
return '';
}, "mDataProp": "ID", sWidth: "40px"
},
{ "aTargets": [1], "mDataProp": "SenderId", sWidth: "100px" },
{ "aTargets": [2], "mDataProp": "SubjectLink", sWidth: "200px" },
{ "aTargets": [3], "mDataProp": "Account", sWidth: "66px" },
{ "aTargets": [4], "mDataProp": "ReceivedDateFormatted", sWidth: "66px" }
],
"aaSorting": [[4, "desc"]],
"fnDrawCallback": function (oSettings) {
$("#inbox .ssDataTable").css("visibility", "visible");
$("#inbox .dataTables_scrollHead").css("visibility", "visible");
},
"fnServerData": function (sSource, aoData, fnCallback) {
$.ajax({
"type": "POST",
"dataType": 'json',
"contentType": "application/json; charset=utf-8",
"url": sSource,
"data": "{'sEcho': '" + JSON.stringify(aoData) + "','msgType' : '" + msgType + "'}",
"success": function (result) {
fnCallback(result); // draw the table
},
"error": function (xhr, ajaxOptions, thrownError) {
alert("There was an error loading your message. Please try again later.");
}
});
}
});
JSON:
HTMLOutput: null
__type: "Messaging"
aaData: Array[25]
iTotalDisplayRecords: 48
iTotalRecords: 48
sColumns: null
sEcho: "[{"name":"sEcho","value":1},{"name":"iColumns","value":5},{"name":"sColumns","value":""},{"name":"iDisplayStart","value":0},{"name":"iDisplayLength","value":25},{"name":"mDataProp_0","value":"ID"},{"name":"mDataProp_1","value":"SenderId"},{"name":"mDataProp_2","value":"SubjectLink"},{"name":"mDataProp_3","value":"Account"},{"name":"mDataProp_4","value":"ReceivedDateFormatted"},{"name":"sSearch","value":""},{"name":"bRegex","value":false},{"name":"sSearch_0","value":""},{"name":"bRegex_0","value":false},{"name":"bSearchable_0","value":true},{"name":"sSearch_1","value":""},{"name":"bRegex_1","value":false},{"name":"bSearchable_1","value":true},{"name":"sSearch_2","value":""},{"name":"bRegex_2","value":false},{"name":"bSearchable_2","value":true},{"name":"sSearch_3","value":""},{"name":"bRegex_3","value":false},{"name":"bSearchable_3","value":true},{"name":"sSearch_4","value":""},{"name":"bRegex_4","value":false},{"name":"bSearchable_4","value":true},{"name":"iSortCol_0","value":4},{"name":"sSortDir_0","value":"desc"},{"name":"iSortingCols","value":1},{"name":"bSortable_0","value":false},{"name":"bSortable_1","value":true},{"name":"bSortable_2","value":true},{"name":"bSortable_3","value":true},{"name":"bSortable_4","value":true}]"
oSettings object :
oSettings: Object
_iDisplayEnd: 0
_iDisplayLength: 25
_iDisplayStart: 0
_iRecordsDisplay: NaN
_iRecordsTotal: NaN
This discussion has been closed.
Replies
Allan
Please find this DataTables debugger link
http://debug.datatables.net/ojowot
Please try this link instead.It shows Server Data function.
http://debug.datatables.net/omobev
If you add `oSettings.jqXHR = ` just before `$.ajax({` I think it should.
Allan
http://debug.datatables.net/apiwek
Allan
http://debug.datatables.net/enaqig
So its not working because iTotalRecords etc are nested inside the `d` property. Try using `fnCallback(result.d);` .
sEcho also looks very odd. It should be an integer.
Allan
Thanks Allan...