DataTables from JS array, onclick() problem
DataTables from JS array, onclick() problem
I have redone my ajax loaded DataTables object to where it now populates using a JS array like demonstrated here: https://datatables.net/examples/data_sources/js_array
The problem is that my onclick inline editor doesn't work anymore, see https://editor.datatables.net/examples/inline-editing/simple line 33
There are no errors in the browser dev tools console.
Do I need to change the way I attach the event listener to the table?
This question has an accepted answers - jump to answer
Answers
I added a debugger statement in my event listener, and the on-click listener is executed properly. The problem looks to be with the editor.inline() method. Still digging into it.
I think my problem is that Editor doesn't know how to deal / match the data from the jsarray variable.
I'm finally getting an error: Unable to automatically determine field from source. Please specify the field name
How do I match up source data from a jsarray with fields in the Editor?
Not sure it will work but you can try with array notation for example
idSrc: 0
. If possible you should convert your data to objects. It will make your life much much much easier :-)Kevin
What do you mean with converting my data to objects? I agree that using the array index isn't ideal.
See this doc for supported data structures. Your server script will need to return the data as objects not arrays.
Take a look at this example. The data source is ajax but the concept is the same for JS data.
Kevin