Get row id on edit

Get row id on edit

russlevyrusslevy Posts: 15Questions: 6Answers: 0
edited September 2015 in Editor

Hi,

My datasource has field id. I am using editor.on('open'). How can I get the row id being edited?

This works but seems like overkill

var id = datatable.fnGetData(editor.modifier()).id

Thanks.

This question has an accepted answers - jump to answer

Answers

  • ThomDThomD Posts: 334Questions: 11Answers: 43
    edited September 2015

    How you get the value of a column depends a bit on what context you are in. When exactly do you want to get this value? Sample code please.

  • russlevyrusslevy Posts: 15Questions: 6Answers: 0
    edited September 2015
    Editor.on('open', function(){
    var id = datatable.fnGetData(Editor.modifier()).id
    })
    
  • ThomDThomD Posts: 334Questions: 11Answers: 43
    edited September 2015

    var id = Editor.field("id").val();

    or

    var id = this.field("id").val();

  • russlevyrusslevy Posts: 15Questions: 6Answers: 0

    That doesn't work because id isn't a field in the editor

  • ThomDThomD Posts: 334Questions: 11Answers: 43

    OK

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    edited September 2015 Answer ✓

    Your method of using modifier() is probably the best way. I would suggest using row().data() rather than the legacy fnGetData method, but either will work.

    Edit - Having a method in Editor to get the ids of the rows being edited sounds sensible, I'll look into that.

    Allan

  • russlevyrusslevy Posts: 15Questions: 6Answers: 0

    Thanks!

This discussion has been closed.