I have an editable table and when the user edits the table, the field 'usernumber' must be also updated with his number ID.
The field 'usernumber' is updated automatically without intervention from user.
$col["editoptions"] = array("defaultValue" => "Default Company");
In this example is possible when add new row, but does not work in update and the user can change the value before submit.
My need is something like this example
$col = array();
$col["title"] = "UserNumber";
$col["name"] = "usernumber";
$col["editable"] = false;
$col["editoptions"] = array("defaultValue" => $usernumber);
$cols[] = $col;
Thanks
You can use afterShowForm event of edit form and reset the field value using JS as required.
e.g.
$opt["edit_options"]["afterShowForm"] = 'function () { jQuery("#usernumber").val('.$username.'); }';
…
$g->set_options($opt);
You can inspect the field id.using firebug and use jquery functions to disable / enable desired field.
To know jquery selector:
http://easycaptures.com/fs/uploaded/1017/9892108434.png
http://easycaptures.com/fs/uploaded/1017/9617668813.png
$col = array();
$col["title"] = "UserNumber";
$col["name"] = "usernumber";
$col["width"] = "45";
$col["align"] = "left";
$opt["edit_options"]["afterShowForm"] = '10';
$cols[] = $col;
Is this a valid option for my request?
Please send complete code, i'll the suggest the changes.
You can email at [email protected]
Using the demo included with the framework (demos/editing/index.php).
With that file is possible to edit the demo DB, on ClientId, Name, Gender and Company.
My question is:
How can I change the demo for user insert/update on ClientId, Name and Gender and not Company.
But everytime a row is inserted/updated, the field Company is also inserted/updated but with a value received by HTTP POST from a previous page and not by user action.
One pratical use for my request is for example:
I have a DB that can be edited by users.
All the users are authenticated with name and password.
The user name is passed to the page by POST or SESSION
When a user makes a change to the DB is necessary to record also is name, so
is possible to check who is responsible for the changes.
For security reasons the name can't be inserted manually. It must be inserted
internally by the code.
The user name is passed by session variables, so is not editable by the user.
Thank you!
PS: The field 'name' or 'Company' are not necessary to be visible on the grid.
They can never appear to user.
You can have default values inserted by code using on_insert event handler.
It is supported in full version (demos/editing/custom-events.php)
You can hide any column using column settings:
$col["hidden"] = true;
For further help, refer docs: http://www.phpgrid.org/docs/#Selecting_Specific_Columns