datatable binding issue from ajax source

datatable binding issue from ajax source

nallagndanallagnda Posts: 8Questions: 1Answers: 0

Iam using ajax data source to bind data table below is my code if the code is executed Iam getting fallowing error
"Uncaught TypeError: Cannot read property 'length' of undefined" can any body help me to solve this issue

function fnLoadTable()
        {
            var oTable = jQuery("#tblSurveysBreakDown").dataTable({
                "aLengthMenu":[10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                "aoColumns": [{ "bSortable": false, "mDataProp": "ClientSurveyId" },
                { "bSortable": false, "mDataProp": "Title" },],
                "iDisplayLength": 10,
                "bPaginate": true,
                "sPaginationType": "bootstrap",
                "bProcessing": true,
                "bServerSide": true,
                "bDestroy": true,
                "bFilter": false,
                "sAjaxSource": 'DataProvider',
                "sAjaxDataProp":"",
                "oLanguage": { "sLengthMenu": "MENU records per page" },
                //"oPaginate": { "sPrevious": "Prev", "sNext": "Next" } },
                //"sDom": 'T<"clear"><"clear"><"col-md-4 padding-top-15" l>r<"col-md-4 padding-top-15 padding-bottom-5 pull-right nopaddRight"C>t<"col-md-6" i><"col-md-6" p>',
                "sAjaxSource": "@Url.Action("AjaxNewSurveysList", "Reports")",
                "fnServerParams": function (aoData)
                {
                 aoData.push($('#stage2').serialize());
                },
                "fnServerData": function (sSource, aoData, fnCallback)
                {
                 $.ajax({ "dataType": 'json', "contentType": "application/json; charset=utf-8",
                     //type: 'POST',
                     "url": sSource,
                     "data": aoData,
                     "success": function (msg) {
                         if (msg.aaData != "")
                         {
                             //oTable.fnAddData(msg.aaData);
                             $("#DivReport").css("display", "block");
                             var json = jQuery.parseJSON(JSON.stringify(msg.aaData));
                             fnCallback(json); $("#tblSurveysBreakDown").show();
                             //var tr = [];
                             //for (var i = 0; i < json.length; i++) {
                             //    tr.push('<tr>');
                             //    tr.push("<td>" + json[i][0] + "</td>");
                             //    tr.push('</tr>');
                             //}
                             //$('#tblSurveysBreakDown').append($(tr.join('')));
                         } else {
                             //ExternalSessionExpiry();
                         }
                     }
                 });
                },
                
            });
            jQuery('#tblSurveysBreakDown .dataTables_length select').addClass("m-wrap small");
        // modify table per page dropdown
        }

Replies

  • allanallan Posts: 63,214Questions: 1Answers: 10,415 Site admin

    Can you link to a test case, as per the forum rules please.

    Allan

This discussion has been closed.