"Remove": Return more than the id back to the server

"Remove": Return more than the id back to the server

jfeyjfey Posts: 10Questions: 0Answers: 0
edited June 2013 in Editor
I have tried a lot but i am still stuck. I need to send back not just the "id" of a set (this is the default behavior) after the user selects "Remove". Since some data sets have the same id but differ in different parameters i need to send back one additional parameter from the selected row.

Example;

o: DT_RowId: 10, id: 4, ....
1: DT_RowId: 10, id: 2, ....
2: DT_RowId: 10, id: 9, ....

is there any way to get hold of that "id" entry?

Any help is very much welcomed.


cheers

Juergen

Replies

  • jfeyjfey Posts: 10Questions: 0Answers: 0
    Ok, i found a solution, but i doubt that it is "elegant":

    I send a combined string from the server like "id:parm1_parm2". Parm1 is one id and parm2 is another id - both combined will lead me to the database entry i am looking for.

    When using the option

    "idSrc" : "id"

    i get the combined "id" in my "remove" event and i am able to find the database entries i am looking for after splitting the values. This could be done on the client side to save some CPU cycles on the server. Fine.

    Still, i hope for a better way to solve the task. Any hints?

    cheers

    Juergen
  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    That's fairly cunning - nice one.

    The way I would recommend doing it is to use the onPreSubmit method ( http://editor.datatables.net/options/#onPreSubmit ) and check if a row is being deleted ( `this.s.action === 'remove'` will tell you when that is the case - I'm going to add that to the event arguments for the next release), and add the data you want to submit to the data object passed into the event handler.

    Regards,
    Allan
This discussion has been closed.