Two questions: Is there a way to force input on the grid edit form to all uppercase?
If I want the default value of a column to be the value of another column in the same table can that be done and how?
For 1)
If you want to do on client side:
You can set them using editoptions
$col = array();
$col[“title”] = “Name”; // caption of column
…
$col[“editoptions”] = array(“onkeyup”=>”this.value=this.value.toUpperCase()”);
$cols[] = $col;
To do this on server side, you can connect on_insert OR on_update event handler and make it strtoupper(). e.g.
$e[“on_insert”] = array(“add_client”, null, true);
$grid->set_events($e);
function add_client($data)
{
$data[“params”][“fullname”] = strtoupper($data[“params”][“fullname”]);
}
// where fullname is $col[“name”] you want to store in caps.
For 2) Please tell when you need to set default value. Is it on add or edit? if edit, dialog or inline?
Is the field exist in grid from which value need to be read?
Thanks I’ll try that for my all caps issue.
For the second part I would like to have a default edit value. For example: User_Level would be displayed with the current level of Guest, Registered User, or Admin in the original column and then a second column of New_User_Level would be defaulted to whatever the current user level is set to so the admin could leave it as is or better change it.
For #2, Demo here: line 51
It loads value of field ‘name’ in ‘gender’ on form load and inline edit.
I feel stupid but I tried the above and my page errors out. What am I doing wrong to the underlined portion?
$col = array();
$col[“title”] = “DBA”;
$col[“name”] = “dba”;
$col[“align”] = “center”;
$col[“width”] = “40”;
$col[“editable”] = true; // this column is editable
$col[“editoptions”] = array(“size”=>25); // with default display of textbox with size 20
$col[“editoptions”] = array(“onkeyup”=>”dba=dba.toUpperCase()”);
$col[“editrules”] = array(“required”=>true); // and is required
$cols[] = $col;
Hello,
dba = dba.toUpperCase() may not work, instead of this.value = this.value.toUpperCase()
Also editoptions array is getting overrided and size=>25 will be ignored.
Try this:
$col = array(); $col["title"] = "DBA"; $col["name"] = "dba"; $col["align"] = "center"; $col["width"] = "40"; $col["editable"] = true; // this column is editable $col["editoptions"] = array("size"=>25, "onkeyup"=>"this.value=this.value.toUpperCase()"); $col["editrules"] = array("required"=>true); // and is required $cols[] = $col;