Hello,
I am using this code:
$col = array();
$col[“title”] = “Phrase H 1”;
$col[“name”] = “pla_hcode1”;
$col[“width”] = “60”;
$col[“stype”] = “select”;
$col[“editable”] = true;
$col[“edittype”] = “select”; // render as select
$sqllogos=”select CONCAT(code, ‘ – ‘,REPLACE($lang, ‘;’, ‘.’)) as v, code as k FROM ghs_h_phrases”;
$str =’–:–;’. $g->get_dropdown_values($sqllogos);
$col[“editoptions”] =array(“value”=>$str);
$col[“formatter”] = “select”; // display label, not value
$col[“formatoptions”] = array(“value”=>$str);
$col[“searchoptions”] = array(“value”=>$str);
$cols[] = $col;
Its working well but the select drop down is not preseleted with the value in the table.
Is this due because I am showing label and storing different value?
Hello,
This line looks redundant:
$col["formatoptions"] = array("value"=>$str);
Second, based on the code below:
select CONCAT(code, ' – ',REPLACE($lang, ';', '.')) as v, code as k FROM ghs_h_phrases
‘code’ should be available in database as it’s the key. And value is basically shown in dropdown as label.
If it still does not work, Please share the screenshot of how the values are stored in database and how they are shown in grid.
In the image, I can see it is showing correct value. If it’s not working as expected in dropdown, please share the screenshot where you are getting unexpected behavior.