I have an issue with custom events.
My goal is to insert into another table two informations:
Serial number (read from the datagrid) and the value of a checkbox
I can show the checkbox on the actual grid but when i change the value nothing is excecuting on the db
i use this code
$e[“on_update”] = array(“add_client”, null, false);
$g->set_events($e);
function add_client($data)
{
global $grid;
$grid->execute_query(“INSERT INTO `dggs_grid`(`serial`, `app`) VALUES ({$data[“serial”]}”,{$data[“app”]}”) “);
}
$out = $g->render(“list1”);
Thank you
Event handler $data var usage should be like: 28$data[“params”][“app”]
You can put: phpgrid_error($data); and it will debug $data array in error box.
Ok, the issue is that he don’t take the params serial (with the debug of the query i can see that he take the value of the checkbox (1) but the value of the serial is empty
$col[“name”] = “SERIAL”;
——-
$str = “INSERT INTO dggs_grid (‘serial’,’app’) VALUES ({$data[“params”][“SERIAL”]},{$data[“params”][“app”]})”;
Could you please help me?
With the debug i see that in $data is present only the value of the checkbox and the ID how can i read all other params in the grid?
Thank
In normal mode, grid sends all $col[“editable”] = true – columns to update.
In excel mode, it only send ID and changed column to server.
You can refer code of demos/editing/custom-events.php and see how it works.