jQuery Datatables large data set Uncaught TypeError: Cannot read property 'mData' of undefined

前端 未结 1 547
长发绾君心
长发绾君心 2021-01-26 19:47

So I get a console error on a large set of rows that I\'m iterating from a database with php. I am initializing this with the metronic theme. As you can see I have my thead and

相关标签:
1条回答
  • 2021-01-26 20:05

    CAUSE

    Number of items in array specified by columns option should match number of <td> elements. You have 12 elements in columns array and 13 <td> elements.

    From the manual:

    Note that if you use columns to define your columns, you must have an entry in the array for every single column that you have in your table (these can be null if you don't which to specify any options).

    SOLUTION

    Add extra object to columns array to match number of columns in the HTML.

    Alternatively you can replace columns with columnDefs entirely for readability.

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

    LINKS

    See jQuery DataTables: Common JavaScript console errors for more information on this and other common console errors.

    0 讨论(0)
提交回复
热议问题