Help I can’t set values in my Multiselect Combobox in extjs4

Ok, there is a little documented trick to setting multiple values in the extjs4.1 combobox when you have multiselect set to true and you are returning your values as a comma delimted string from the store. I know what you are thinking, and no I don’t mean you are storing your multiple values in the database as a comma delimited string, but let’s say you used STUFF or something like that to get the values back as a nice delimited string.

Your data would look like this if you alerted the value in the record.

Your combobox would look like this after the record was loaded:

But you want the combobox to look like this:

What you will need to do is transform your comma delimited string into an array and then set the value like this:

// this goes right before your form.loadRecord(record) code

var values = rec.get('delimited_string_field').split(',');
Ext.getCmp('your_multiselect_box').setValue(values);   

It’s that easy!

One thought on “Help I can’t set values in my Multiselect Combobox in extjs4

  1. Thanks for this. The documentation says the “value” config option can be assigned an Object, but I didn’t put two and two together to try passing it an array of values until reading your blog. It worked! I.e.,

    var selectedValues = [8, 39];
    Ext.create(‘Ext.form.field.ComboBox’, {

    values: selectedValues
    }

Leave a Reply