Multiple Select dropdown issue

QuestionsMultiple Select dropdown issue
Matthew asked 7 years ago

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;

3 Answers
Abu Ghufran answered 7 years ago

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]

Matthew answered 7 years ago

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;

Abu Ghufran answered 7 years ago

Glad to know it's resolved.

Your Answer

1 + 20 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?