How do I use preEdit when editing multiple rows at the same time
How do I use preEdit when editing multiple rows at the same time

I think I am having the same problem as this but cannot figure it out from the answer given.
https://datatables.net/forums/discussion/51227/preedit-and-multiple-editing
->on( 'preEdit', function ($editor, $id, $values ) {
$editor
->field( 'ordersvalves.searchstring' )
->setValue($values['ordersmaster']['type'] . $values['ordersmaster']['model'] . $values['ordersvalves']['size'] . $values['ordersvalves']['chainwheel']);
} )
If I am editing multiple rows at the same time I get the same result for all rows.
Can anyone clarify?
Thanks
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi,
preEdit
will be triggered once for each row, but it is triggered for all rows before actually saving any of them. So the value saved here would be the one form the last row that is edited.What you can do is this:
Note the
&
which denotes the "pass by reference" that was referred to in the thread you linked to. That means that you can modify the value and that will be reflected in the variable the caller sees as well.Allan
Thanks Allan,
I tried using a preSubmit on the client side and it seems to work as expected. Is one way better than the other or will both work the same?
Thanks,
Both work the same. The benefit of server-side is that you're preventing any attacks that could send data direct outside of the browser. If you're in a safe intranet, that shouldn't be an issue.
Colin