"oCol is undefined" error in DataTables when not using columnDefs
"oCol is undefined" error in DataTables when not using columnDefs
I am facing a problem with DataTables in my project. When I do not use the columnDefs setting, I receive the following error in the console: "oCol is undefined", and information is loaded into the table. However, if I add the lines of code that define columnDefs, the error disappears and the table works loading the corresponding data, with the drawback that it does not show all the columns (34) nor does it overflow, it is as if it ignored the columns that They do not have space to be shown (26-34)
columnDefs: [
{ width: "150px", targets: [0, 1, 11, 12, 13, 16, 17, 18, 20, 21, 22, 24, 25], orderable: false, },
{ width: "100px", targets: [3, 15, 19, 32, 33], orderable: false, },
{ width: "120px", targets: [2, 4, 5, 6, 7, 8, 9, 10, 14, 23, 26, 27, 28, 29, 30, 31], orderable: false, },
],
Answers
correction, without the definition of columnDefs the data is not loaded into the table
Your description is a bit confusing and the code snippet isn't enough to help debug. Please post a link to your page or test case replicating the issue so we can see what you have to offer suggestions.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Sounds like you may have the Responsive extension enabled to hide columns that don't fit.
Kevin
Could be due to not having the same number of columns in the
tbody
as there are in thethead
. Again will will need to see the problem to help debug.Kevin