On preEdit i want to select record and store it in to array, so that i can pass values postEdit
On preEdit i want to select record and store it in to array, so that i can pass values postEdit
lavania
Posts: 12Questions: 5Answers: 0
in DataTables 2
->on('preEdit', function ($editor, $id, $values) use ($db, &$original_data) {
})
how to select record
Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
Answers
You can define a session variable for example. Save whatever you like in that variable.
And do something with it on "postEdit" and unset it eventually.
$values is the record you are editing. If you edit multiple records you would need to loop through the array of records and save the one you want in the session variable.
I would use your debugger and look at $values in case you are editing multiple records at the same time. If you edit a single record it is just that record in $values.
On preEdit, I want to run select query e.g.
SELECT * from table where id=$id
then want to pass the result to postEdit, to keep record of which variable is changed and what was the original value and what is thw new value
This is wrong, sorry. "preEdit" and "postEdit" are executed once for each record regardless of how many records you are editing when using multi edit.
Ok, thanks. Now I understand your requirement a little better. I've done something like that myself, too. Let me take a look ...
I would use "validatedEdit" and not "preEdit" because you probably don't want to save a record that eventually fails validation, I guess.
This uses Editor's db-handler and its raw method.