PDA

View Full Version : Having issues with ComboBox.transform



keithritt
24 Aug 2011, 1:14 PM
Hello,

I am having an issue when I try to transform a select box that already has multiple items selected. Only the first item in the list is selected after the transform.



<select multiple="multiple" size="5" id="select_box>
<option value="a" selected="selected">A</option>
<option value="b">B</option>
<option value="c">C</option>
<option value="d">D</option>
<option value="e" selected="selected">E</option>
</select>


<script>
Ext.create('Ext.form.ComboBox',
{
fieldLabel: 'TEST',
transform: 'select_box',
multiSelect: true
});
</script>

skirtle
27 Aug 2011, 2:33 AM
Looks like a bug to me. Suggest you file a report.

Simple workaround:


var vals = Ext.Array.pluck(
Ext.Array.filter(
Ext.Array.from(Ext.getDom('select_box').children),
function(option) {
return option.selected;
}
),
'value'
);

var cb = Ext.create('Ext.form.ComboBox', {
fieldLabel: 'TEST',
transform: 'select_box',
multiSelect: true
});

cb.setValue(vals);

keithritt
29 Aug 2011, 3:48 PM
Thanks - that worked great and I did file the bug:
http://www.sencha.com/forum/showthread.php?145434-ComboBox.transform-not-working-with-multiSelects&p=642564#post642564

keithritt
30 Aug 2011, 6:32 AM
you can save a step and a couple lines by using the value attribute:



Ext.create('Ext.form.ComboBox', {
fieldLabel: 'TEST',
transform: 'select_box',
multiSelect: true,
value: Ext.Array.pluck(
Ext.Array.filter(
Ext.Array.from(Ext.getDom('select_box').children),
function(option) {
return option.selected;
}
),
'value'
)
});