Hi Abu,
I'm trying to implement a field which allows multiple values to be selected. The below code using Select2 allows me to add a new record and select multiples as well as edit an existing record with a single value in it. However when I edit a record with multiple values already in the field it doesn't bring up those values, it just puts a blank in the field. I checked in the backend table and the comma separated list of values is saved in the table so the data is there, it's just how do I get it to pull through as separate values when loading the field with Select2?
$col = array();
$col["title"] = "Asset"; // caption of column
$col["name"] = "AssetID"; // field name, must be exactly same as with SQL prefix or db field
$col["width"] = "70";
$col["fixed"] = true;
$col["align"] = "center";
$col["editable"] = true;
$str = $g->get_dropdown_values("select DISTINCT AssetNumber as k, AssetNumber as v from mexassets ORDER BY AssetNumber");
$str = ':;' . $str;
$col["stype"] = "select";
$col["edittype"] = "select";
$col["searchoptions"] = array("value" => $str, "separator" => ":", "delimiter" => ";");
$col["editoptions"] = array("value" => $str, "separator" => ":", "delimiter" => ";");
$col["editoptions"]["multiple"] = "true";
$col["editoptions"]["dataInit"] = "function(){ setTimeout(function(){ $('select[name=AssetID]').select2({width:'80%', dropdownCssClass: 'ui-widget ui-jqdialog'}); },200); }";
$cols[] = $col;
I am unable to generate this issue.
You can check online or in demo browser that comes with purchased package file.
http://www.phpgrid.org/demo/demos/integrations/select2-tags.php
Compare your code with it. If it still don't work email me grid code, database sql test dump to regenerate case.
Email: [email protected]
Thanks Abu. I had a look at the code here:
http://www.phpgrid.org/demo/demos/integrations/select2-tags.phps
I was able to resolve the problem by removing the inverted quotes around the word true.
What I had: $col["editoptions"]["multiple"] = "true";
What works: $col["editoptions"]["multiple"] = true;