refresh after "on_after_update" event

Questionsrefresh after "on_after_update" event
Pedro couto asked 2 years ago

Good Morning, Abu.

I have a problem with an “on_after_update” event.

I have this 2 functions:

function after_update($data){
      global  $g;
      $Terminal = $data[“Terminal”];
      $Bonos =  $data[“params”][“Bonos”];
      $Sql = “UPDATE Datos SET BonosPrev = $Bonos where Terminal = ‘$Terminal'”;
      $result = $g->execute_query($Sql);

}
function update_terminal($data)
  {

      global  $g;
      global $username;
      $Terminal = $data[“Terminal”];
      $Establecimiento =  $data[“params”][“Establecimiento”];
      $Bonos =  $data[“params”][“Bonos”];
      $BonosPrev =  $data[“params”][“BonosPrev”];
      $Sql = “INSERT INTO journal (Fecha, Terminal,Establecimiento,Operacion, Descripcion,Importe,Notes) VALUES (‘”.date(‘Y-m-d H:i:s’).”‘,’$Terminal’, ‘$Establecimiento’,’Bonos Añadidos   $Bonos ($BonosPrev)’,’$Bonos Bonos’,0,’Usuario : $username’)”;
      $result = $g->execute_query($Sql);

  }
all works fine, but the grid dont refresh automatically on after update event , i have to press f5 or reload button.
Is any way to “push” reload button from code? or call refresh grid?
i know that after update, the grid refresh the content, and i tryed to put  the

      $Sql = “UPDATE Datos SET BonosPrev = $Bonos where Terminal = ‘$Terminal'”;
      $result = $g->execute_query($Sql);
at the end of the update function, but it dosn´t work.
Any help?
thank you very much for your support.

2 Answers
Abu Ghufran Staff answered 2 years ago

Hi,

You need to put following in the end of after_update event handler.

$id = data["Terminal"]
$res = array("id" => $id, "success" => true)
echo json_encode($res);

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Pedro answered 2 years ago

Thank you very much. Meanwhile i found a solution ,

it was : $opt[\”reloadedit\”] = true; that force the refresh.

Your Answer

5 + 19 =

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?