Having the same number of table header columns and table data columns is a requirement when using DataTables. However, I am currently dealing with an issue where the number of my <th>
tags fluctuates by plus or minus 2 based on certain conditions, while using the render function to display the corresponding <td>
columns.
Unsurprisingly, DataTables is throwing an error (
Cannot read property 'style' of undefined
) due to this discrepancy.I can't seem to find a way to eliminate the need for render functions or statically render the table headers.
columns: [
{
data: "some_id",
render: function (data, type, row) {
return "some content";
},
{
data: "some_id",
render: function (data, type, row) {
return "some content";
}
]
This section is where the issue lies.