DataTables from JS array, onclick() problem

DataTables from JS array, onclick() problem

stephanbstephanb Posts: 36Questions: 11Answers: 0
edited March 2021 in Free community support

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

  • stephanbstephanb Posts: 36Questions: 11Answers: 0
    edited March 2021

    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.

  • stephanbstephanb Posts: 36Questions: 11Answers: 0

    I think my problem is that Editor doesn't know how to deal / match the data from the jsarray variable.

  • stephanbstephanb Posts: 36Questions: 11Answers: 0

    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?

  • kthorngrenkthorngren Posts: 21,178Questions: 26Answers: 4,923
    Answer ✓

    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

  • stephanbstephanb Posts: 36Questions: 11Answers: 0

    What do you mean with converting my data to objects? I agree that using the array index isn't ideal.

  • kthorngrenkthorngren Posts: 21,178Questions: 26Answers: 4,923

    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

This discussion has been closed.