Editor: Are postEdit/postCreate events able to get the table row related to the edit?

Editor: Are postEdit/postCreate events able to get the table row related to the edit?

bworsfoldbworsfold Posts: 14Questions: 4Answers: 0

I am hoping to be able to find the table row that was edited and change the style class for the row to show that it has been edited. Is this possible through these events? So far, it looks like "this" in the event is just a reference to the editor. I know that I can see the data being edited, but I am after the actual table row (tr) element.

Answers

  • bworsfoldbworsfold Posts: 14Questions: 4Answers: 0

    So, I have a kludge where I go through each row in the table and then compare it's id with the data.id. I am not so happy with this approach, so if there are any more direct options, that would be great.

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

    You can use the modifier() method to get the item that edit() was called with. This will likely be a row index, or row node, which you can then use with the row().node() method to get the tr element in question.

    Regards,
    Allan

  • bworsfoldbworsfold Posts: 14Questions: 4Answers: 0

    That would be sweet! I will give it a try today. Thanks Allan.

  • bworsfoldbworsfold Posts: 14Questions: 4Answers: 0

    So, this works fine. Thanks so much for the pointer Allan. Very powerful option! This actually is a real nice addition so that users can see what has been modified in the table.

    editor.on( 'postEdit', function ( e, json, data ) {
        $(this.modifier()).addClass('data-changed')
    } );
    
  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin
    edited April 2015

    The Editor CSS should actually animate a flash of the table row that has been edited, like it does in this example. Does that not work for you?

    It does use CSS animation, so it wouldn't work in older browsers.

    Regards,
    Allan

  • bworsfoldbworsfold Posts: 14Questions: 4Answers: 0

    Not really. They want to be able to see the fact they row has changed permanently, that is until they refresh the page. They actually have a two step process. You do your edits on the data, then either commit the changes or roll them back. So, they want to be able to see the edits prior to committing the changes.

    It is a bit old school, but something they want.

    :)

    Have a great day Allan.

    Brad

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

    Got it - thanks for the clarification. Your method is ideal then :-).

    Allan

This discussion has been closed.