Uncaught TypeError: Cannot read property 'length' of undefined

Uncaught TypeError: Cannot read property 'length' of undefined

SourcenewSourcenew Posts: 1Questions: 1Answers: 0

/*
i get this Error:

jquery.dataTables.min.js:3314
Uncaught TypeError: Cannot read property 'length' of undefined

*/
function format(d) {
var ResultString = '

'; console.log(d.StoneDetails); for (i = 0; i < d.StoneDetails.split("##").length; i++) { ResultString += ''; } // `d` is the original data object for the row ResultString += '
سنگتعدادمتراژقیمت
' + d.StoneDetails.split("##")[i].split("||")[0] + '' + d.StoneDetails.split("##")[i].split("||")[1] + '' + d.StoneDetails.split("##")[i].split("||")[2] + '' + d.StoneDetails.split("##")[i].split("||")[3] + '

';
return ResultString;
}

    $(document).ready(function () {
        var table = $('#example').DataTable({
            "ajax": "BuyList.aspx?GetData=1",
            "columns": [
                {
                    "className": 'details-control',
                    "orderable": false,
                    "data": null,
                    "defaultContent": ''
                },
                { "data": "BuyID" },
                { "data": "Facname" },
                { "data": "BuyDate" },
                { "data": "BuyDes" }
            ],
            "order": [[1, 'asc']],
            filter: false,
            "dom": '<"top"i>rt<"bottom"flp><"clear">'
        });
        $('#example tbody').on('click', 'td.details-control', function () {
            var tr = $(this).closest('tr');
            //console.log(table);
            var row = table.row(tr);

            if (row.child.isShown()) {
                // This row is already open - close it
                row.child.hide();
                tr.removeClass('shown');
            }
            else {
                // Open this row
                row.child(format(row.data())).show();
                tr.addClass('shown');
            }
        });

    });

/*
my web service return sample:

{"data":[{"BuyID":"1","Facname":"اصفهان","BuyDate":"1394/04/29","BuyDes":"gf","StoneDetails":"مرمر||500||12||10,000"},{"BuyID":"2","Facname":"اصفهان","BuyDate":"1394/04/29","BuyDes":"fg","StoneDetails":""}]}

*/

This discussion has been closed.