Getting id when deleting a row in Editor

Getting id when deleting a row in Editor

amweissamweiss Posts: 13Questions: 3Answers: 0

Hi all
I'm using Datatables Editor and when deleting a row I would like to get the id of the row that was deleted. In the table, I have a user_id for each row. I thought maybe the callback would work, like this

editor.on( 'remove', function ( e, json, data ) {
        //  get data.user_id and do something with it
    } );

But that doesn't do anything except it says data is undefined. Is it even possible to the user_id for the row that was just deleted?

Thanks

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,569Questions: 26Answers: 4,996

    I think you will want to use initRemove to get the data. The data is an array so for the first item you will use data[0].user_id.

    Kevin

  • amweissamweiss Posts: 13Questions: 3Answers: 0

    Thanks.. to test this out, I've tried this (just to see if I can get the user_id) by clicking on a cell and then leaving the cell.

    editor.on( 'preBlur', function ( e, json, data ) { alert( data[0].user_id ); } );
    in firebug I get TypeError: data is undefined..so it still seems the data is undefined

  • kthorngrenkthorngren Posts: 21,569Questions: 26Answers: 4,996
    Answer ✓

    preBlur has only e as a parameter and remove has only e, json as parameters. initRemove has e, json, data parameters.

    Kevin

  • amweissamweiss Posts: 13Questions: 3Answers: 0

    Got it...thanks

This discussion has been closed.