I have an issue with Datatables
. I also went through this link which didn't yield any results. I have included all the prerequisites where I'm parsing data directly into the DOM. Kindly help me to fix this issue.
Script
$(document).ready(function() { $('.viewCentricPage .teamCentric').dataTable({ "bJQueryUI": true, "sPaginationType": "full_numbers", "bPaginate": false, "bFilter": true, "bSort": true, "aaSorting": [ [1, "asc"] ], "aoColumnDefs": [{ "bSortable": false, "aTargets": [0] }, { "bSortable": true, "aTargets": [1] }, { "bSortable": false, "aTargets": [2] }], }); });
mData can be given in a number of different ways which effect its behaviour: integer - treated as an array index for the data source. This is the default that DataTables uses (incrementally increased for each column). string - read an object property from the data source.
What Causes TypeError: Cannot Read Property of Undefined. Undefined means that a variable has been declared but has not been assigned a value. In JavaScript, properties and functions can only belong to objects.
FYI dataTables requires a well formed table. It must contain <thead>
and <tbody>
tags, otherwise it throws this error. Also check to make sure all your rows including header row have the same number of columns.
The following will throw error (no <thead>
and <tbody>
tags)
<table id="sample-table"> <tr> <th>title-1</th> <th>title-2</th> </tr> <tr> <td>data-1</td> <td>data-2</td> </tr> </table>
The following will also throw an error (unequal number of columns)
<table id="sample-table"> <thead> <tr> <th>title-1</th> <th>title-2</th> </tr> </thead> <tbody> <tr> <td>data-1</td> <td>data-2</td> <td>data-3</td> </tr> </tbody> </table>
For more info read more here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With