"oCol is undefined" error in DataTables when not using columnDefs

"oCol is undefined" error in DataTables when not using columnDefs

yiyombyiyomb Posts: 2Questions: 1Answers: 0

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

  • yiyombyiyomb Posts: 2Questions: 1Answers: 0

    correction, without the definition of columnDefs the data is not loaded into the table

  • kthorngrenkthorngren Posts: 21,324Questions: 26Answers: 4,949

    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

  • kthorngrenkthorngren Posts: 21,324Questions: 26Answers: 4,949

    oCol is undefined

    Could be due to not having the same number of columns in the tbody as there are in the thead. Again will will need to see the problem to help debug.

    Kevin

Sign In or Register to comment.