On Update Event

QuestionsOn Update Event
Alfonso Cabrera asked 9 years ago

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.

2 Answers
Abu Ghufran answered 9 years ago

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;
}

Alfonso Cabrera answered 9 years ago

Thank you Abu!, I had a problem with my function.

Your Answer

0 + 13 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?