Inline editing of DataTable without JSON key information

Inline editing of DataTable without JSON key information

ghherlinghherlin Posts: 20Questions: 3Answers: 0

Hallo,
I have a table filled by a JSON array of arrays, the primary key being the first field, and I am attempting to use inline editing.

The examples I have found use a JSON array of objects, the key of which is used to select the datum to be edited when clicking on a field.

I end up with a "Uncaught Unable to find row identifier For more information, please refer to https://datatables.net/tn/14". Which I have read attentively.

I have added as idSrc the fieldName value of the first Editor column, to no avail.

Is there a way of adding the datum key information or fieldName matching info to the columns of the dataTable?
Thanks in advance
George

Replies

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    I have added as idSrc the fieldName value of the first Editor column, to no avail.

    Can you post a snippet of what you did?

    The idSrc docs state this for array data:

    When using DataTables with array based row data, this option gives the array index from which to read the row id form the row's data source array.

    Kevin

  • ghherlinghherlin Posts: 20Questions: 3Answers: 0

    Hallo, Kevin,
    Well spotted and thank you. I'd missed that. It works.
    (BTW is there some way for users to fix or suggest fixes for a typo?)

    But there is another problem: the editor field input comes up blank, instead of being seeded with the value in the DataTable.

    Any ideas?
    George

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    BTW is there some way for users to fix or suggest fixes for a typo?

    Post the link and the suggested changes in this or a new thread.

    But there is another problem: the editor field input comes up blank, instead of being seeded with the value in the DataTable.

    See if this example with arrays helps. If not please update it or provide a link to your page or a test case showing the issue.
    http://live.datatables.net/vagapezu/23/edit

    Kevin

  • ghherlinghherlin Posts: 20Questions: 3Answers: 0

    Magnificent!

    It all works perfectly.

    May I suggest adding this to your official examples? Adding all ine array index numbers as names in 2 places was a little short of obvious.

    Thanks again
    George

  • ghherlinghherlin Posts: 20Questions: 3Answers: 0

    Oh, and the typo is "form" instead of "from" in the integer box at the top of the idSrc reference page https://editor.datatables.net/reference/option/idSrc

    Over to you

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Thanks for pointing out the typo - I've got it fixed in our git repo for the site and will push it out soon.

    Regarding the suggestion of an example with arrays of data for Editor. I actually thought we did have one, but I suspect that might have been from a legacy version. We find that developers can keep track of data much easier with object properties rather than arrays, where it easy to mix indexes if you add or remove columns, but yes, it probably would be worth having a single example of how this can be done.

    Many thanks to Kevin for your example. You are a Titan of the DataTables world sir.

    Allan

Sign In or Register to comment.