jQuery Datatables大数据集Uncaught TypeError:无法读取未定义的属性’mData’

所以我在一个大的行集上得到一个控制台错误,我正在用PHP从数据库迭代。 我正在用metronic主题初始化它。 正如你所看到的,我有我的thead和tbody。

我怀疑问题可能与输出的大小有关,可能需要使用其他方法,任何指导意见

这是数据表的metronic init:

 table.dataTable({ // Internationalisation. For more info refer to http://datatables.net/manual/i18n "language": { "aria": { "sortAscending": ": activate to sort column ascending", "sortDescending": ": activate to sort column descending" }, "emptyTable": "No data available in table", "info": "Showing1 _START_ to _END_ of _TOTAL_ entries1", "infoEmpty": "No entries found", "infoFiltered": "(filtered1 from _MAX_ total entries)", "lengthMenu": "Show _MENU_ entries", "search": "Search:", "zeroRecords": "No matching records found" }, // Or you can use remote translation file //"language": { // url: '//cdn.datatables.net/plug-ins/3cfcc339e89/i18n/Portuguese.json' //}, // Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout // setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js). // So when dropdowns used the scrollable div should be removed. //"dom": "<'row'r>t<'row'>", "bStateSave": true, // save datatable state(pagination, sort, etc) in cookie. "columns": [{ "orderable": false }, { "orderable": true }, { "orderable": false }, { "orderable": false }, { "orderable": true }, { "orderable": true }, { "orderable": true }, { "orderable": true }, { "orderable": true }, { "orderable": true }, { "orderable": true }, { "orderable": false }], "lengthMenu": [ [5, 15, 20, -1], [5, 15, 20, "All"] // change per page values here ], // set the initial value "pageLength": 5, "pagingType": "bootstrap_full_number", "language": { "search": "My search: ", "lengthMenu": " _MENU_ records", "paginate": { "previous":"Prev", "next": "Next", "last": "Last", "first": "First" } }, "columnDefs": [{ // set default column settings 'orderable': false, 'targets': [0] }, { "searchable": false, "targets": [0] }], "order": [ [1, "asc"] ] // set first column as a default sort by asc }); 

原因

columns选项指定的数组中的项数应与

元素的数量匹配。 columns数组和13个

元素中有12个元素。

从手册 :

请注意,如果使用columns来定义列,则必须在数组中为表中的每个列指定一个条目(如果不指定任何选项,则这些条目可以为null )。

将额外对象添加到columns数组以匹配HTML中的列数。

或者,您可以完全使用columnDefs替换columns以提高可读性。

 "columnDefs": [{ "orderable": false, "searchable": false, "targets": [0] }, { "orderable": false, "targets": [2, 3, 11, 12] } ], 

链接

有关此错误和其他常见控制台错误的详细信息,请参阅jQuery DataTables:常见JavaScript控制台错误。

Name Source Email Customer Created Login Active Role Incentive View Switch Email
<a href='https://stackoverflow.com/questions/33091881/jquery-datatables-large-data-set-uncaught-typeerror-cannot-read-property-mdata/user-edit?uid=""'>View <a href='https://stackoverflow.com/questions/33091881/jquery-datatables-large-data-set-uncaught-typeerror-cannot-read-property-mdata/switch?email=""'> Switch <input type='checkbox' name='email-list[]' value=''>