I have a combo like
items: {
xtype: 'combo',
id: 'combo',
queryMode: 'local',
displayField: 'name',
valueField: 'id',
store: Ext.create('Ext.data.Store', {
fields: ['id', 'name', 'mydata'],
data: [
{'id': '1', 'name': 'John Smith', 'mydata': ["3", "4"]},
{'id': '2', 'name': 'Albert Einstein', 'mydata': ["1", "2"]}
]
}),
listeners: {
select: function( combo, records, eOpts ) {
alert(records[0].get('mydata')); // records is undefined
}
}
}
But when i using
var combo = Ext.getCmp('combo');
//combo.select("1");
combo.setValue("1");
combo.fireEvent('select');
Then alert(records[0].get('mydata')); // records is undefined
fail. How to fix this problem thanks.
Here is my code http://jsfiddle.net/LZ8XU/
For some reason, the select method of the Ext comboBox doesn't fire the select event. It seems to me from your question that you want to set a value, and manually fire the select event. If so, there are a couple more fields that are necessary to pass; specifically the comboBox itself and the selected record.
Here's an implementation that does it.
var combo = Ext.getCmp('combo');
var toselect = "Albert Einstein";
combo.select(toselect);
var record = combo.getStore().findRecord('name', toselect);
combo.fireEvent('select', combo, [record]);
Why not listen to the change
event instead?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With