I have a dropdown (for regions) in an include member. It's an array. How can I get it to display the data in a dropdown? I have the 'member' included and it works in other programs that don't use this grid quite well. I'm also able to successfully use a database table for a 'select'. But how do I get the data from this "include" member into my dropdown. Here is what I've tried (stateList['US'] is in the included code):
$col = array();
//$states_arr = arrayToSelect($stateList['US'], $remitToState);
$col["title"] = "AP State"; // caption of column, can use HTML tags too
$col["name"] = "remitToState"; // grid column name, same as db field or alias from sql
$col["dbname"] = "remitToState";
$col["width"] = "35";
$col["search"] = true;
$col["editable"] = true;
$col["edittype"] = "select"; // render as select
//$str = $g->get_dropdown_values(arrayToSelect($stateList['US'], $remitToState));
$str = $g->get_dropdown_values(array(arrayToSelect($stateList['US'])));
//$col["editoptions"] = arrayToSelect($stateList['US'], $remitToState);
//$col["editoptions"] = array($stateList['US']);
$col["editoptions"] = array("value"=>":;".$str);
//$col["formatter"] = "select"; // display label, not value
//$col["stype"] = "select";
$cols[] = $col;
Hi,
Pasting from docs:
To render as select (dropdown),with static values "key:value;key:value;key:value"
$col["edittype"] = "select";
$col["editoptions"] = array("value"=>'10:$10;20:$20;30:$30;40:$40;50:$50');
You need to iterate array to make similar string and pass to "value" param. The get_dropdown_values() do exactly that from sql query.
Ok, I tried what I THINK you said. I have an array of State values and names, so I did this (stateList contains the states, like 'AL' => 'Alabama',) etc ..:
$col = array();
$str = (($stateList['US'])) ;
$col["title"] = "AP State";
$col["name"] = "remitToState";
$col["dbname"] = "remitToState";
$col["width"] = "35";
$col["search"] = true;
$col["editable"] = true;
$col["edittype"] = "select"; // render as select
$col["editoptions"] = array("value"=>":;".$str);
$col["formatter"] = "select";
$cols[] = $col;
This gives me a value of "undefined" in the dropdown. I really don't want to have to "hard-code" these 50 state values in a 'select' for each column that I need them in. Am I doing something wrong here? The variable $str contains the array of state keys and values.