Hello,
I implemented a subgrid and added the virtual column “Mover” that contains two buttons. Each one of this buttons should call a procedure that is stored in the database. Those database procedures work correctly already, and I also checked that the functions attached to those buttons are correctly receiving the ID (via alerts).
The code for the “Mover column” has the following default value:
$col[“default”] = “<button onclick=’moveDown({id})’ class=’btn’> <i class=’fa fa-arrow-down’></i></button>
<button onclick=’moveDown({id})’ class=’btn’> <i class=’fa fa-arrow-up’></i></button>”;
My question is: How can i call my database procedures inside the function, with a syntax similar to the one used inside “on_insert” events? E.G. $subgrid->execute_query(“CALL moveUp(id);”);
Thanks in advance, and I hope my question is well formulated
Hi,
I’ve explained similar question here: https://www.gridphp.com/support/questions/change-the-order-in-which-rows-are-presented/
Inside the moveDown(123) JS function, you can call a bulk update function to pass the ID and operation to backend. e.g.
function moveDown(id) { fx_bulk_update('move-down',id,-1); }
And now in server side code, you can connect an on_update event handler and use this operation label:
https://www.gridphp.com/demo/demos/editing/bulk-edit.phps line 141
if ($data["params"]["bulk"] == "move-down") { $id = $data["params"]["data"]; // here you can code your logic to do bulk processing $g->execute_query("CALL movedown($id)"); die; }