I have a field which I want to multiselect filter on but it’s not working. When I select a value the grid displays “no value found”. I can multiselect on the ID field no problems but the field that contains data with commas in it won’t work.
This is the code for the ID field which is just an autoincrementing integer. This multiselects fine.
$col = array();
$col[“title”] = “Id”;
$col[“name”] = “id”;
$col[“hidden”] = false;
$str = $g->get_dropdown_values(“Select DISTINCT id as k, id as v from 2009stats order by id asc”);
$col[“stype”] = “select-multiple”;
$col[“searchoptions”][“value”] = $str;
$cols[] = $col;
This is the code for the Name field which doesn’t work. The data is in the form “Surname, Firstname”
$col = array();
$col[“title”] = “Name”;
$col[“name”] = “Name”;
$col[“width”] = “100”;
$col[“fixed”] = true;
$col[“editable”] = true;
$col[“search”] = true;
$col[“frozen”] = true;
$str = $g->get_dropdown_values(“Select distinct Name as k, Name as v from 2009stats order by name asc”);
$col[“stype”] = “select-multiple”;
$col[“searchoptions”][“value”] = $str;
$cols[] = $col;
Any thoughts on how to get this working?
Thanks
I’ve just done a workaround and replaced the comma with a fullstop and this works as I’d expect. It’s not the best solution but all I can think of for now:
$col = array();
$col[“title”] = “Name”;
$col[“name”] = “Namedot”;
$col[“dbname”] = “REPLACE(Name,’,’,’.’)”;
$str = $g->get_dropdown_values(“Select distinct REPLACE(Name,’,’,’.’) as k, REPLACE(Name,’,’,’.’) as v from 2009stats order by Name asc”);
$col[“stype”] = “select-multiple”;
$col[“searchoptions”][“value”] = $str;
$cols[] = $col;
$g->select_command = “SELECT *, REPLACE(Name,’,’,’.’) as Namedot FROM 2009stats”;
I replaced the comma , with U+00B8: Cedilla ¸
This looks almost identical and works so happy days.
Thats fine as well. I have found solution for this issue as well. If your data contains comma, you need to surround the key in single quotes using sql concat. e.g.
$str = $g->get_dropdown_values(“Select distinct concat(\”‘\”,Name,\”‘\”) as k, Name as v from 2009stats order by name asc”);