How can I insert the value of a+b into c?
$col = array();
$col["title"] = "LOG"; // caption of column
$col["name"] = "a"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
$col["width"] = "200";
$col["align"] = "center";
$col["editable"] = FALSE;
$col["hidden"] = False;
$col["search"] = true;
$cols[] = $col;
$col = array();
$col["title"] = "LOG"; // caption of column
$col["name"] = "b"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
$col["width"] = "200";
$col["align"] = "center";
$col["editable"] = FALSE;
$col["hidden"] = False;
$col["search"] = true;
$cols[] = $col;
$col = array();
$col["title"] = "LOG"; // caption of column
$col["name"] = "c"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
$col["width"] = "200";
$col["align"] = "center";
$col["editable"] = FALSE;
$col["hidden"] = False;
$col["search"] = true;
$cols[] = $col;
If your fields are editable, you can follow this faq:
http://www.phpgrid.org/faqs/#80
As in your code, these are editable=>false, so you can update value of 'c' on backend using on_insert / on_update callback function.
$e["on_update"] = array("update_field", null, true);
$e["on_insert"] = array("update_field", null, true);
$g->set_events($e);
function update_field($data)
{
$data["params"]["c"] = $data["params"]["a"] + $data["params"]["b"]
}
Here what ever value of 'a' & 'b' are posted back they will be summed and used in sql query.