Hi,
i need to assign default value to a column, if possible?
I have try this but not work
$id_user = $_SESSION['id_user'];
$col = array();
$col["title"] = "Id Utente";
$col["name"] = "id_user";
# $col["width"] = "300"; // not specifying width will expand to fill space
$col["sortable"] = false; // this column is not sortable
$col["search"] = false; // this column is not searchable
$col["editable"] = true;
$col["edittype"] = "text";
$col["editoptions"] = $id_user;
$col["hidden"] = false;
$cols[] = $col;
To render as textbox with size 20, and initial value in textbox to 10
$col["editoptions"] = array("size"=>20, "value"=>'10');
… pasted from http://phpgrid.org/docs
Yes, even this would work if you dont need size.
probably a typing mistake of missing '.
$col["editoptions"] = array("value"=>'$id_user');
So ok
$col = array();
$col["title"] = "Id Utente";
$col["name"] = "IDUTENTE";
$col["sortable"] = false; // this column is not sortable
$col["search"] = false; // this column is not searchable
$col["editable"] = true;
$col["editoptions"] = array("value"=>$id_user);
$col["hidden"] = false;
$cols[] = $col;
but there is a problem, when I insert the first record in the IDUTENTE column takes the value of the variable in the correct way, if I insert a new record after, the value is blank.
Use this code to assign the value to the variable
session_start ();
$ id_user = $ _SESSION ['id_user'];
Perhaps the variable is empty after the first insertion, how can I do to preserve the value?
I have try this but non work
session_start();
$id_user = $_SESSION['id_user'];
session_register($id_user);
$col["editoptions"] = array("value"=>1);
I did some tests and I noticed that if I put a fixed value (1) and do not use sessions, the problem remains. That is, the first record is inserted correctly with the value 1, the next entries give null value.
Help me please!!!
Well, it should work but i will retry it again. Alternate approach is to use on_insert / on_update callback event handlers and set this session value from PHP. For ref, review example file custom-events.php in your paid package.
Regards,
I'll try the alternative approach to the events, but I'd like to understand what's wrong with what I did, thanks
Hi, I tried with the example custom-event but I have several problems, I ask you kindly help me on the question that I have made previously, thank you and good day
Just to help others, i'm logging the solution here.
"recreateForm"=>true was required in add/edit option of form dialog to persist that default value.
Closing this case.
I am having the same issue and i cannot seem to resolve.
I have added the edit options, but it enters value as 0
what else do i have to do when adding?
$col = array();
$col["title"] = "Users ID";
$col["name"] = "users_id";
$col["sortable"] = false; // this column is not sortable
$col["search"] = false; // this column is not searchable
$col["editable"] = false;
$col["editoptions"] = array("value"=>54);
$col["hidden"] = false;
$cols[] = $col;