Uncaught TypeError: Cannot read properties of undefined (reading 'style')
Uncaught TypeError: Cannot read properties of undefined (reading 'style')
I want to dynamically change column visible based on a variable. For this I run the code after the ajax request is successful and it works. But I am also getting the following error.
if (!userObj.IsManagment) {
s.columns(4).visible(false);
}
Uncaught TypeError: Cannot read properties of undefined (reading 'style')
at db (datatables.min.js:89:39)
at sa (datatables.min.js:41:375)
at B.<anonymous> (datatables.min.js:163:438)
at B.iterator (datatables.min.js:134:423)
at B.<anonymous> (datatables.min.js:163:409)
at Function.adjust (datatables.min.js:137:349)
at B.<anonymous> (datatables.min.js:163:208)
at B.iterator (datatables.min.js:134:423)
at B.<anonymous> (datatables.min.js:162:483)
at B.visible (datatables.min.js:137:349)
This question has an accepted answers - jump to answer
Answers
That's almost always caused by a miss match in the number of columns in the table. Make sure your table has 5 column.
If that doesn't help, please link to a page showing the issue so we can offer some help.
Allan
thank you for the answer
I'm fetching columns and rows as json from server side. I found the solution by changing the visible property a on the server side. For now, I can say the problem is solved.
When I make column visible false after the datatable is loaded, I think it mixes the row and column numbers as you said.
Thank you again.