json is correct but the table is not showing

json is correct but the table is not showing

aplavaplav Posts: 11Questions: 0Answers: 0
edited November 2011 in General
Hi Allan,
I'm using ASP.Net and modified example for ASP.Net from the datatables.com.I'm not getting any errors but the table is not showing up. The JSON is valid based on http://jsonlint.com. Thanks.
The script:


$(document).ready(function() {
$('#myDataTable').dataTable({
"bJQueryUI": true,
"bPaginate": true,
"bLengthChange": true,
//"bFilter": true,
//"bStateSave": true,
"bSort": true,
"bAutoWidth": false,
"bProcessing": true,
"bServerSide": true,
"iDisplayLength": 10,
"sAjaxSource": "DataTableServer1.aspx",
"aoColumns": [
{ "sTitle": "CIN", "sWidth": "20%", "bSortable": "true" },
{ "sTitle": "SSN", "sWidth": "40%", "bSortable": "true" },
{ "sTitle": "CaseNumber", "sWidth": "40%", "bSortable": "true" },
{ "sTitle": "LName", "sWidth": "40%", "bSortable": "true" },
{ "sTitle": "FName", "sWidth": "40%", "bSortable": "true" },
{ "sTitle": "RecordID", "sWidth": "40%", "bSortable": "true" }
],
"aaSorting": [[1, 'asc']],
"oLanguage": {
"sLengthMenu": "Page length: _MENU_",
"sSearch": "Filter:",
"sZeroRecords": "No matching records found"
},

"sPaginationType": "full_numbers",
"fnServerData": function(sSource, aoData, fnCallback) {
$.ajax({
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
// "success": function(msg) {
// //alert(msg.d);
// fnCallback(msg.d);
// }

});


}


});
});



HTML:




CIN


SSN


CaseNumber


LName


Fname


RecordID







The output JSON:
{"sEcho": 1,"iTotalRecords": 68,"iTotalDisplayRecords": 10,"aaData": [["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"]]}

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    I don't see anything obviously wrong there. Can you give us a link to your page please - that would be very helpful? Also, are there any errors on the Firebug console?

    Thanks,
    Allan
  • aplavaplav Posts: 11Questions: 0Answers: 0
    Allan, thank you for answering. Unfortunately page is behind the firewalls. There are no errors in console. I'm using ASP.net(VB.net) so I put the server side code in the Page_load event of the codebehind aspx.vb page to make it easier. The Console just show postThe response subtab of the Console tab of the Firebug shows the output JSON as I gave above. The HTML part of the Firebug shows valid html with nothing in tags(because nothing is displayed except words "Processing". My server code is the slightly modified version of asp.net example on your site. I create JSON string in the code then do Response.Write(str) as in the example. If it could be helpful I could post the server side code but it is in VB.net.
    By the way am I correct that if I get this JSON output in the Response subtab of the Console tab in the Firebug then this JSON is returned to the datatables on the client side and supposed to be displayed?
    There is another interesting thing. Everything that is supposed to show above the content of the data table(search box, column names with the mouse cursor changing to hand when hover on the column name to allow sorting) is displayed. The page FirstPreviousNextLast are displayed under the column names.
    Below is the info from Firebug

    Post tab:

    bRegex false
    bRegex_0 false
    bRegex_1 false
    bRegex_2 false
    bRegex_3 false
    bRegex_4 false
    bRegex_5 false
    bSearchable_0 true
    bSearchable_1 true
    bSearchable_2 true
    bSearchable_3 true
    bSearchable_4 true
    bSearchable_5 true
    bSortable_0 true
    bSortable_1 true
    bSortable_2 true
    bSortable_3 true
    bSortable_4 true
    bSortable_5 true
    iColumns 6
    iDisplayLength 10
    iDisplayStart 0
    iSortCol_0 1
    iSortingCols 1
    mDataProp_0 0
    mDataProp_1 1
    mDataProp_2 2
    mDataProp_3 3
    mDataProp_4 4
    mDataProp_5 5
    sColumns
    sEcho 1
    sSearch
    sSearch_0
    sSearch_1
    sSearch_2
    sSearch_3
    sSearch_4
    sSearch_5
    sSortDir_0 asc
    Source
    sEcho=1&iColumns=6&sColumns=&iDisplayStart=0&iDisplayLength=10&mDataProp_0=0&mDataProp_1=1&mDataProp_2=2&mDataProp_3=3&mDataProp_4=4&mDataProp_5=5&sSearch=&bRegex=false&sSearch_0=&bRegex_0=false&bSearchable_0=true&sSearch_1=&bRegex_1=false&bSearchable_1=true&sSearch_2=&bRegex_2=false&bSearchable_2=true&sSearch_3=&bRegex_3=false&bSearchable_3=true&sSearch_4=&bRegex_4=false&bSearchable_4=true&sSearch_5=&bRegex_5=false&bSearchable_5=true&iSortingCols=1&iSortCol_0=1&sSortDir_0=asc&bSortable_0=true&bSortable_1=true&bSortable_2=true&bSortable_3=true&bSortable_4=true&bSortable_5=true

    Response:
    {"sEcho": 1,"iTotalRecords": 68,"iTotalDisplayRecords": 10,"aaData": [["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"]]}

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


















    HTML tab:

    {"sEcho": 1,"iTotalRecords": 68,"iTotalDisplayRecords": 10,"aaData": [["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"],["KKKKK","111-11-1111","44444444","AAA","AAA","1111"]]}
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    Hmmmm - I'm afraid I'm still not seeing the problem! Could you possibly try the latest version of DataTables (the 1.8.3.dev nightly from http://datatables.net/download) and remove your fnServerData, and add in "sServerMethod": "POST". This is a new feature in 1.8.3 (or whatever I end up calling it - might be 1.9 :-) ) to make sending by post easier.

    The other thing to note is that iTotalRecords and iTotalDisplayRecords should be the same unless you have filtering applied - which you don't in this case - so they should both be 68.

    Allan
This discussion has been closed.