Hi Abu!
I have a problem getting the new value of a column, when ever I update a record, I need to get the new value of the column "cant_entregada" but I always get the value when a added the record.
Below is my code.
$e["on_insert"] = array("agregar_detalle", null, true);
$e["on_update"] = array("actualizar_detalle", null, true);
$grid->set_events($e);
function agregar_detalle(&$data)
{
$id = intval($_GET["rowid"]);
$data["params"]["idDesplazamiento_Medicina"] = $id;
$cant_pend = intval(Obten_CantPendiente($id,$data["params"]["cant_entregada"]));
$data["params"]["cant_pendiente"] = $cant_pend;
}
function actualizar_detalle(&$data)
{
$id = intval($_GET["rowid"]);
$data["params"]["idDesplazamiento_Medicina"] = $id;
$cant_pend = intval(Obten_CantPendiente($id,$data["params"]["cant_entregada"]));
$data["params"]["cant_pendiente"] = $cant_pend;
}
The function Obten_CantPendiente makes a calculation and returns a int value, the value that I get back I put it in another column. But the problem is that I'm not getting the new value of $data["params"]["cant_entregada"] when I update the record.
Could you help me out.
I use a master-detail grid. The problem is in the detail grid.
When I add a record the function agregar_detalle works perfect, but not when I update.
Some debugging would be required.
If you are using cellEdit mode in that grid, it only post changed cell in $data.
In any case, you can know the details and reason, by printing $data.
function actualizar_detalle(&$data)
{
// these lines will push data array in error box to debug
ob_start();
print_r($data);
phpgrid_error(ob_get_clean());
$id = intval($_GET["rowid"]);
$data["params"]["idDesplazamiento_Medicina"] = $id;
$cant_pend = intval(Obten_CantPendiente($id,$data["params"]["cant_entregada"]));
$data["params"]["cant_pendiente"] = $cant_pend;
}