PDA

View Full Version : [CLOSED] ComboBox select event fired twice on selecting an option



Chods
9 Mar 2011, 6:59 AM
var dropDownStore = Ext.create('Ext.data.Store', {
model: 'Product',
data: [{
id: '1',
value: 'All',
themes: [{
id: '1',
value: 'All'
},{
id: '2',
value: 'Theme 1'
}]
},{
id: '2',
value: 'Category 1'
},{
id: '3',
value: 'Category 2'
},{
id: '4',
value: 'Category 3'
}]
});

var productCombo = Ext.create('Ext.form.ComboBox', {
queryMode: 'local',
width: 300,
labelWidth: 0,
displayField: 'value',
store: dropDownStore,
listeners: {
select: {
fn: function(field, value) {

alert("Select fired")
}
}
}
});

margozzi
9 Mar 2011, 8:06 PM
I have seen this as well. The first time the value is an empty array []. The second time i get the real value. It seems that there are many bugs reported against the ComboBox. Perhaps this widget deserves a good code review?

Chods
10 Mar 2011, 2:06 AM
Thats exactly what i see aswell, only the value is an array. I have to select value[0] to get the selected item.

bhutten
15 Mar 2011, 6:28 AM
I see this as well, using the Ext.form.ComboBox example from the PR3 docs (modified so it actually runs...)


Ext.onReady(function() {
var testCombo = new Ext.form.ComboBox({
triggerAction: 'all',
queryMode: 'local',
renderTo: Ext.getBody(),
store: new Ext.data.ArrayStore({
id: 0,
fields: [
'myId',
'displayText'
],
data: [
[1, 'item1'],
[2, 'item2']
]
}),
valueField: 'myId',
displayField: 'displayText'
});

testCombo.on('select', function(field, record, index) {
console.log("on select");
}, this);
});

hulstein
15 Mar 2011, 8:03 AM
I added a check in my select handler for this:



listeners: {
select: function( thisCombo, selection ) {
if ( selection.length > 0 ) {
// do your thing
}
}
}

mitchellsimoens
6 Sep 2011, 5:12 AM
Please don't append anything to the title that states the state of the bug. This is a dup of http://www.sencha.com/forum/showthread.php?134147