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

rpanditrpandit Posts: 14Questions: 0Answers: 0
edited November 2013 in DataTables 1.9
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

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    It looks like there is something funny going on with the JON returned. Can you link us to a test page showing the issue or use the DataTables debugger to give us a trace please?

    Allan
  • rpanditrpandit Posts: 14Questions: 0Answers: 0
    Hi Allan,
    Please find this DataTables debugger link

    http://debug.datatables.net/ojowot
  • rpanditrpandit Posts: 14Questions: 0Answers: 0
    Hi Allan,
    Please try this link instead.It shows Server Data function.

    http://debug.datatables.net/omobev
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Unfortunately, because you override fnServerData, the debugger can't see what JSON was loaded from the server :-(.

    If you add `oSettings.jqXHR = ` just before `$.ajax({` I think it should.

    Allan
  • rpanditrpandit Posts: 14Questions: 0Answers: 0
    I tried what you asked me to do. But i don't see any data in the table now.

    http://debug.datatables.net/apiwek
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    No that' didn't work unfortunately. I'm going to need a link to the page to be able to assist I'm sorry to say.

    Allan
  • rpanditrpandit Posts: 14Questions: 0Answers: 0
    How about this link? It has JSON loaded from the server.

    http://debug.datatables.net/enaqig
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Awesome - thank you.

    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
  • rpanditrpandit Posts: 14Questions: 0Answers: 0
    Worked..
    Thanks Allan...
This discussion has been closed.