Check documentation for the latest version 6.0 of dhtmlxSuite beforeUpdate DHTMLX Docs

beforeUpdate

The event occurs before updating values in database and can cancel default update statement or validate incoming values.

$conn->event->attach("beforeUpdate",handlerFunc);

Parameters handlerFunc:

Availability:

  • Available for Grid, TreeGrid, Tree, Scheduler, DataView, Form

Sample:

// creates and runs a custom update statement using values coming in request, 
// cancels the default update
function myUpdate($action){
   $res->query("UPDATE Countries SET item_nm='{$action->get_value('name')}' 
                WHERE item_id='{$action->get_id()}'");
   $action->success();
}
 
// or
// checks if the value of name is empty, then cancels update. 
// Otherwise, proceeds with the default update
function myUpdate($action){
    if($action->get_value("name")=="")
    $action->invalid();
} 
 
// or
// sets a new value for name and proceeds with the default update
function myUpdate($action){
    $new_value = rand(0,100);
    $action->set_value("name",$new_value);
}
 
$conn->event->attach("beforeUpdate","myUpdate");
Back to top