"TypeError: Cannot read properties of undefined (reading 'buttons') at ce.fn.init.initComplete (
"TypeError: Cannot read properties of undefined (reading 'buttons') at ce.fn.init.initComplete (
Link to test case: https://live.datatables.net/filipiwa/1/edit
Debugger code (debug.datatables.net):
Error messages shown: TypeError: Cannot read properties of undefined (reading 'buttons') at ce.fn.init.initComplete
Description of problem: When I call the data from a page via AJAX the page works but when I use a local variable I get TypeError
Hello, I'm trying to create a test case for several issues I have with my table, since I cannot use the original data I tried creating a local JSON variable. For some reason, I'm getting this error when I use that.
This question has an accepted answers - jump to answer
Answers
The error is due to this line in
initComplete
:The
table
variable you are assigning using the Datatables init code is not always ready/assigned at the timeinitComplete
executes. You can get an instance of the API usingthis.api()
withininitComplete
, for example:You reference
this.api()
in other locations ofinitComplete
. You can assign the variable as the first line then change all the references to use the variable.Updated example:
https://live.datatables.net/tawadifu/1/edit
Kevin
@kthorngren, thank you! This is greatly appreciated!