Unable to set property

Unable to set property

JAQ2JAQ2 Posts: 1Questions: 1Answers: 0

Hello,

I dynamically create a table after an Ajax call, then initialize it as a Datatable, then do rows.add(rows).

$("#ReportTable").DataTable({
    "destroy": true,
    "lengthChange": false,
    "stateSave": false,
    "sort": false,
    "paging": false,
    "dom": "rt",
    "columns": tableCols        
});

The Table does not populate with the rows that I give it. If I take out the "destroy" property, it will populate the 2nd time I run the script.

The first time the script runs I get "Unable to set property '_DT_CellIndex' of undefined or null reference".
jquery.dataTables.js (1765,4)

Subsequent times I get "Unable to get property 'parentNode' of undefined or null reference"
jquery.dataTables.js (9149,3)

http://live.datatables.net/jecikohi/1/

The errors don't show on the test page.

Thank you,

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 22,169Questions: 26Answers: 5,104
    Answer ✓

    You are getting this error in your example:

    Uncaught TypeError: Cannot set property '_DT_CellIndex' of undefined

    The problem is the HTML table has just one column but you are trying to build a Datatable with more than one column. You can use the columns.title to have Datatables build the columns. Your tableCols variable would need both columns.data and columns.title objects.

    Kevin

This discussion has been closed.