Server-side paginated processing, aaData OK but no data displaying

Server-side paginated processing, aaData OK but no data displaying

MrBaseball34MrBaseball34 Posts: 96Questions: 0Answers: 0
edited March 2014 in General
I am using a modified version of the server-side pagination demo and the data is returning correctly. But the table is not showing ANYTHING except the headers. Every TD is empty. If I echo out the json value in the javascript here: fnCallback(json) the aaData contains the correct JSON:
[code]
{"aaData":[{"FILENAME":"/DownloadFile2.aspx?File=q%3a%5cPeople%5c1026704%5c791%5cLetters%5cMonthlyCISRLostDesignationMemo1026704PR20131001.PDF","DOC_NAME":"10/1/2013 | Monthly CISR Lost Designation Memo","PRINT_DATE":"10/1/2013","EVENT_CODE":"","STATE":"","DESIGNATION":"CISR","PROGRAM_CODE":"","COURSE NAME":"","PR":"","DISTRIBUTION":"","PROGRAM_DESCRIPTION":"","YEAR":""},{"FILENAME":"/DownloadFile2.aspx?File=q%3a%5cPeople%5c1026704%5c791%5cLetters%5cMonthlyCICLostDesignationMemo1026704PR20131001.PDF","DOC_NAME":"10/1/2013 | Monthly CIC Lost Designation Memo","PRINT_DATE":"10/1/2013","EVENT_CODE":"","STATE":"","DESIGNATION":"CIC","PROGRAM_CODE":"","COURSE NAME":"","PR":"","DISTRIBUTION":"","PROGRAM_DESCRIPTION":"","YEAR":""},{"FILENAME":"/DownloadFile2.aspx?File=q%3a%5cPeople%5c1026704%5c791%5cLetters%5cNewCICDesigneeMemoLicRid1026704date20130928.PDF","DOC_NAME":"9/30/2013 | New CIC Designee Memo","PRINT_DATE":"9/30/2013","EVENT_CODE":"","STATE":"","DESIGNATION":"CIC","PROGRAM_CODE":"","COURSE NAME":"","PR":"","DISTRIBUTION":"","PROGRAM_DESCRIPTION":"","YEAR":""},{"FILENAME":"/DownloadFile2.aspx?File=q%3a%5cPeople%5c1026704%5c791%5cLetters%5cNewCISRDesigneeMemoLicRid1026704date20130928.PDF","DOC_NAME":"9/30/2013 | New CISR Designee Memo","PRINT_DATE":"9/30/2013","EVENT_CODE":"","STATE":"","DESIGNATION":"CISR","PROGRAM_CODE":"","COURSE NAME":"","PR":"","DISTRIBUTION":"","PROGRAM_DESCRIPTION":"","YEAR":""},{"FILENAME":"/DownloadFile2.aspx?File=q%3a%5cPeople%5c1026704%5c791%5cLetters%5cNewCRMDesigneeMemoLicRid1026704date20130928.PDF","DOC_NAME":"9/30/2013 | New CRM Designee Memo","PRINT_DATE":"9/30/2013","EVENT_CODE":"","STATE":"","DESIGNATION":"CRM","PROGRAM_CODE":"","COURSE NAME":"","PR":"","DISTRIBUTION":"","PROGRAM_DESCRIPTION":"","YEAR":""},{"FILENAME":"/DownloadFile2.aspx?File=q%3a%5cPeople%5c1026704%5c791%5cLetters%5cCRMCourseAttendanceLicRid1026704date20130928.PDF","DOC_NAME":"9/30/2013 | CRM Course Attendance","PRINT_DATE":"9/30/2013","EVENT_CODE":"","STATE":"","DESIGNATION":"CRM","PROGRAM_CODE":"","COURSE NAME":"","PR":"","DISTRIBUTION":"","PROGRAM_DESCRIPTION":"","YEAR":""},{"FILENAME":"/DownloadFile2.aspx?File=q%3a%5cPeople%5c1026704%5c791%5cLetters%5cCICInstituteAttendanceOutOfStateMemoLicRid1026704date20130928.PDF","DOC_NAME":"9/30/2013 | CIC Institute Attendance Out of State Memo","PRINT_DATE":"9/30/2013","EVENT_CODE":"","STATE":"","DESIGNATION":"CIC","PROGRAM_CODE":"","COURSE NAME":"","PR":"","DISTRIBUTION":"","PROGRAM_DESCRIPTION":"","YEAR":""},{"FILENAME":"/DownloadFile2.aspx?File=q%3a%5cPeople%5c1026704%5c791%5cLetters%5cCISRCourseAttendanceOutOfStateMemoLicRid1026704date20130928.PDF","DOC_NAME":"9/30/2013 | CISR Course Attendance Out of State Memo","PRINT_DATE":"9/30/2013","EVENT_CODE":"","STATE":"","DESIGNATION":"CISR","PROGRAM_CODE":"","COURSE NAME":"","PR":"","DISTRIBUTION":"","PROGRAM_DESCRIPTION":"","YEAR":""},{"FILENAME":"/DownloadFile2.aspx?File=q%3a%5cEvents%5cOther%5c2013%5c20130913PRPA%5c20130913PRPAAttendanceSummary.PDF","DOC_NAME":"9/25/2013 | Attendance_Summary","PRINT_DATE":"9/25/2013","EVENT_CODE":"20130913PRPA","STATE":"PR","DESIGNATION":"CISR","PROGRAM_CODE":"","COURSE NAME":"Insuring Personal Auto Exposures","PR":"","DISTRIBUTION":"","PROGRAM_DESCRIPTION":"","YEAR":""},{"FILENAME":"/DownloadFile2.aspx?File=q%3a%5cEvents%5cOther%5c2013%5c20130927PRIP%5cEval20130927PRIP1026704.pdf","DOC_NAME":"Licensee_Evaluation_Packet","PRINT_DATE":"","EVENT_CODE":"20130927PRIP","STATE":"PR","DESIGNATION":"CISR","PROGRAM_CODE":"STATE","COURSE NAME":"Insuring Commercial Property","PR":"","DISTRIBUTION":"","PROGRAM_DESCRIPTION":"","YEAR":""}]}
[/code]

However, the table is completely empty (screenshot):
http://www.scic.com/files/eddie/datatables.png

I have not made public and cannot at this time.

Any ideas as to why this may be happening?

Replies

  • MrBaseball34MrBaseball34 Posts: 96Questions: 0Answers: 0
    Here's my javascript to initialize and load the table:
    [code]
    var oCache = {
    iCacheLower: -1
    };

    function fnSetKey(aoData, sKey, mValue) {
    for (var i = 0, iLen = aoData.length ; i < iLen ; i++) {
    if (aoData[i].name == sKey) {
    aoData[i].value = mValue;
    }
    }
    }

    function fnGetKey(aoData, sKey) {
    for (var i = 0, iLen = aoData.length ; i < iLen ; i++) {
    if (aoData[i].name == sKey) {
    return aoData[i].value;
    }
    }
    return null;
    }

    function fnDataTablesPipeline(sSource, aoData, fnCallback) {
    var iPipe = 5; /* Ajust the pipe size */

    var bNeedServer = false;
    var sEcho = fnGetKey(aoData, "sEcho");
    var iRequestStart = fnGetKey(aoData, "iDisplayStart");
    var iRequestLength = fnGetKey(aoData, "iDisplayLength");
    var iRequestEnd = iRequestStart + iRequestLength;
    oCache.iDisplayStart = iRequestStart;

    /* outside pipeline? */
    if (oCache.iCacheLower < 0 || iRequestStart < oCache.iCacheLower || iRequestEnd > oCache.iCacheUpper) {
    bNeedServer = true;
    }

    /* sorting etc changed? */
    if (oCache.lastRequest && !bNeedServer) {
    for (var i = 0, iLen = aoData.length ; i < iLen ; i++) {
    if (aoData[i].name != "iDisplayStart" && aoData[i].name != "iDisplayLength" && aoData[i].name != "sEcho") {
    if (aoData[i].value != oCache.lastRequest[i].value) {
    bNeedServer = true;
    break;
    }
    }
    }
    }

    /* Store the request for checking next time around */
    oCache.lastRequest = aoData.slice();

    if (bNeedServer) {
    if (iRequestStart < oCache.iCacheLower) {
    iRequestStart = iRequestStart - (iRequestLength * (iPipe - 1));
    if (iRequestStart < 0) {
    iRequestStart = 0;
    }
    }

    oCache.iCacheLower = iRequestStart;
    oCache.iCacheUpper = iRequestStart + (iRequestLength * iPipe);
    oCache.iDisplayLength = fnGetKey(aoData, "iDisplayLength");
    fnSetKey(aoData, "iDisplayStart", iRequestStart);
    fnSetKey(aoData, "iDisplayLength", iRequestLength * iPipe);

    $.getJSON(sSource, aoData, function (json) {
    /* Callback processing */
    oCache.lastJson = jQuery.extend(true, {}, json);

    if (oCache.iCacheLower != oCache.iDisplayStart) {
    json.aaData.splice(0, oCache.iDisplayStart - oCache.iCacheLower);
    }
    json.aaData.splice(oCache.iDisplayLength, json.aaData.length);

    fnCallback(json)
    });
    }
    else {
    json = jQuery.extend(true, {}, oCache.lastJson);
    json.sEcho = sEcho; /* Update the echo for each response */
    json.aaData.splice(0, iRequestStart - oCache.iCacheLower);
    json.aaData.splice(iRequestLength, json.aaData.length);
    fnCallback(json);
    return;
    }
    }
    $(document).ready(function () {
    var oTable = $("#archive_table").dataTable({
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": '/Home/LoadArchive',
    "fnServerData": fnDataTablesPipeline,
    "aoColumns": [{"mdata": "FILE", sDefaultContent: ""},
    // This is .Net and I'm using this to build the columns array. IT is dynamic, each page may have different "columns"
    @for (int i = 0; i < ViewBag.Header.Count; i++)
    {
    if (ViewBag.Header[i] != "FILENAME")
    {
    {"mdata": "@ViewBag.Header[i]", sDefaultContent: ""},
    }
    }
    ]
    });
    });
    [/code]
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Your JSON data doesn't include the information required by server-side processing. Specifically the sEcho, iTotalRecords and iTotalDisplayRecords parameters. See: http://datatables.net/usage/server-side .

    If you don't need server-side processing (i.e. less that ~50'000 rows) then just disable the bServerSide option.

    Allan
This discussion has been closed.