我有一個像ExtJS的4.1組合 - 如何讓選擇功能火的時候調用combo.setValue
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
}
}
}
組合但當使用
var combo = Ext.getCmp('combo');
//combo.select("1");
combo.setValue("1");
combo.fireEvent('select');
然後我alert(records[0].get('mydata')); // records is undefined
失敗。如何解決這個問題,謝謝。
這是我的代碼http://jsfiddle.net/LZ8XU/
是的,在調用select()方法時,select事件不會自動觸發。它們應該像按鈕的切換方法一樣包含一個suppressEvent布爾參數。 –
@Kyle Fransham:你能幫我一下嗎?請幫我用http:// stackoverflow.com/downloads/default.aspx?displaylang=zh-cn請幫我看看http://stackoverflow.com/questions/21521112/extjs-combobox-change-even-code-executed-on-page-load –