Hi!
I am making selectboxes which works fine, but i would like to add options that are not available in the table i take it from.
Means, i would like to add one blankd option, and some others. But i dont want to pick them from the db.
This is because i need to select nothing or "" in some cases.
Here is my code:
$col = array();
$col["title"] = "Customer Account Manager";
$col["name"] = "CustomerAccountManagerId";
$col["editable"] = false;
$col["formatter"] = "select";
$col["width"] = "80";
$col["edittype"] = "select"; // render as select
# fetch data from database, with alias k for key, v for value
$str = $g->get_dropdown_values("select distinct User_Id as k, User_Name as v from user where UserGroup=6");
$col["editoptions"] = array(
"value"=>$str,
"onchange" => array(
"sql"=>"select * from user",
"search_on"=>"User_Id",
"callback" => "fill_form" )
);
//$col["stype"] = "select"; // enable dropdown search
$col["searchoptions"] = array("value" => ":;".$str);
$cols[] = $col;
Thanks!
mattias
Amazing – thanks!
If i do this in bulkedit it doesnt work although – can i make an option called "Empty" that inserts "" into the cell, or how to do it?
This is not an answer, but I would 1) like to express that I also would be interested in being able to set the value of a field to "" for bulk edit and 2) I would like to know if there is a way during onchange within editoptions to have a blank value as an option. I have used your method successfully for when the dropdown is first loaded, but during onchange I am limited to the results. I have come up with a workaround, which is to take the sql for the onchange event and do a "UNION (SELECT '' as k, '' as v FROM DUAL)", which adds in the blank value for the dropdown. But it would be cleaner if the grid allowed it.