Open editor instance of a specific row by its id

Open editor instance of a specific row by its id

sdroulerssdroulers Posts: 43Questions: 14Answers: 0
edited February 2018 in Bug reports

I would like to edit a specific row (by calling a javascript function) based on its id.

Documentation give as an example of the row_selector option :

var table = $('#example').DataTable();
var row = table.row('#row-42');

Which actually doesn't work on my page.

I thought editiing it by adding :

editor.edit(row);

Having a look at the data retrieved from the server, it looks like the following:

{data: [{DT_RowId: "row_42",…}], options: {,…}, files: []}
data:[{DT_RowId: "row_42",…}]
files :[]
options :{,…}

which looks strange to me since the id format is not the same. Am I missing something?

EDIT Sorry about the spamming, the forum looks a bit tricky today ...

This question has an accepted answers - jump to answer

Answers

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

    Yeah - having issues with the forum software update. Its not going as smoothly as I expected - sorry!

    The edit() method will accept a row-selector as the first argument - so you could just use:

    editor.edit('#row-42');
    

    Another option would be to use:

    editor.edit( row.index() );
    

    Allan

  • sdroulerssdroulers Posts: 43Questions: 14Answers: 0
    edited February 2018

    That's really strange, I just tried :

     editor.edit('#row_127')   //ok with all data
    

    whereas:

     editor.edit('#row-127')   //empty Editor instance
    

    Maybe it's my setup which is wrong

    PS: good luck with the forum :)

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

    Sorry - I see in your original post you did have an underscore. It should match whatever the id in your table is. Both are valid ids.

    Allan

  • sdroulerssdroulers Posts: 43Questions: 14Answers: 0

    But isn't the id format determined by Datatables? It looked strange that infact my data displayed differently of the normal behaviour

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

    The row_ prefix is added by Editor's server-side libraries by default. I just had a typo in my original reply, I should have had an underscore. Unless there is a bigger issue?

    Allan

  • sdroulerssdroulers Posts: 43Questions: 14Answers: 0

    Perfectly clear thanks

This discussion has been closed.