In order to make development easy and without writing a lot of manual code we have created a method
setAfterCrudAction( string $oper, string $sql, array $param ) method.
With a help of this method we should set only the SQL command and parameters for it.
Note that this command or set of commands are executed after the CRUD operation.
Moreover the operation will be executed only when the CRUD for the main table was succesfull.
We can set a unlimited commands to be executed.
Below is a example which update the name after from the edit after it was succesfull.
<?php require_once '../../../jq-config.php'; // include the jqGrid Class require_once ABSPATH."php/jqGrid.php"; // include the driver class require_once ABSPATH."php/jqGridPdo.php"; // Connection to the server $conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD); // Tell the db that we use utf-8 $conn->query("SET NAMES utf8"); // Create the jqGrid instance $grid = new jqGridRender($conn); // Write the SQL Query $grid->SelectCommand = 'SELECT CustomerID, CompanyName, Phone, PostalCode, City FROM customers'; // Set the table to where you update the data $grid->table = 'customers'; // Set output format to json $grid->dataType = 'json'; $grid->setPrimaryKeyId('CustomerID'); // Let the grid create the model $grid->setColModel(); // Set the url from where we obtain the data $grid->setUrl('grid.php'); // Set some grid options $grid->setGridOptions(array( "rowNum"=>10, "rowList"=>array(10,20,30), "sortname"=>"CustomerID" )); $grid->setColProperty('CustomerID', array("editoptions"=>array("readonly"=>true))); // For demonstration purposes only we will update the Customer name adding at end of // the field U after the data is updated from the user // This command is executed after edit $cid = jqGridUtils::GetParam('CustomerID'); // This command is executed immediatley after edit occur. $grid->setAfterCrudAction('edit', "UPDATE customers SET CompanyName = CONCAT(CompanyName,' -U') WHERE CustomerID=?",array($cid)); // You can write a set of command which will be run after edit // $grid->setAfterCrudAction('edit', "UPDATE table2 SET ... WHERE ",array(..)); // $grid->setAfterCrudAction('edit', "UPDATE tableN SET ... WHERE ",array(..)); // Also you can do the same for add and del // $grid->setAfterCrudAction('add', "UPDATE table1 SET ... WHERE ",array(..)); // $grid->setAfterCrudAction('add', "UPDATE tableN SET ... WHERE ",array(..)); // Enable navigator $grid->navigator = true; // Enable only editing $grid->setNavOptions('navigator', array("excel"=>false,"add"=>false,"edit"=>true,"del"=>false,"view"=>true, "search"=>false)); // Close the dialog after editing $grid->setNavOptions('edit',array("closeAfterEdit"=>true,"editCaption"=>"Update Customer","bSubmit"=>"Update")); // Enjoy $grid->renderGrid('#grid','#pager',true, null, null, true,true); $conn = null; ?>