Hi Abu, quick question. I have a column I need to hide on add but display on grid, this also has a default value set which I think is causing an issue?
$col = array();
$col["title"] = "Status"; // caption of column
$col["name"] = "Status"; // grid column name
//$col["editable"] = true;
//$col["hidden"] = false; // hide on grid
//$col["editrules"]["readonly"] = true;
$col["show"] = array("list"=>true, "add"=>false, "edit"=>true, "view"=>true);
$col["width"] = "30";
$col["editoptions"]["defaultValue"] = "Active";
$cols[] = $col;
As it stands the default value of 'Active' doesn't insert to db, if I comment out the col show line and uncomment editable as below it does insert but shows on the add form?
$col = array();
$col["title"] = "Status"; // caption of column
$col["name"] = "Status"; // grid column name
$col["editable"] = true;
$col["width"] = "30";
$col["editoptions"]["defaultValue"] = "Active";
$cols[] = $col;
I would recommend to set default value using on_insert event handler.
When you hide, it is removed from add form.
$e["on_insert"] = array("add_client", null, true);
$grid->set_events($e);
function add_client($data)
{
$data["params"]["Status"] = "Active";
}
Thanks Abu, much appreciated.
I already have a function adding/inserting data but the format is slightly different to the solution you posted?
Currently I use;
'{$data[params][Status]}',
Tried adding your $data["params"]["Status"] = "Active"; but it throws errors
Hi Abu, it doesn't now throw an error but inserts a 0 or a 1 into the db, random?
values ($client_id,
'{$data[params][inputby]}',
'{$data[params][Status]}'='Active',
'{$data[params][CompDate]}',
Changing to
'{$data[params][Status]}Active', works but not sure how!
Thanks anayway