关于Combox的使用总结
原创
©著作权归作者所有:来自51CTO博客作者ccna_zhang的原创作品,请联系作者获取转载授权,否则将追究法律责任
1:关于ComboBox中mode的属性(Ext Js 3.x)
mode : String
Acceptable values are: <div > 'remote' : Default <p >Automatically loads the st...
- 'remote':DefaultAutomatically loads thestore the first time the trigger is clicked. If you do not want the store to be automatically loaded the first time the trigger is clicked, set to 'local' and manually load the store. To force a requery of the store every time the trigger is clicked see lastQuery.
- 'local':ComboBox loads local data
-
var combo = new Ext.form.ComboBox({
renderTo: document.body,
mode: 'local',
store: new Ext.data.ArrayStore({
id: 0,
fields: [
'myId', // numeric value is the key
'displayText'
],
data: [[1, 'item1'], [2, 'item2']] // data is local
}),
valueField: 'myId',
displayField: 'displayText',
triggerAction: 'all'
});
2: 在Ext Js 4.x中ComboBox的应用
// The data store containing the list of states
var states = Ext.create('Ext.data.Store', { fields: ['abbr', 'name'],
data : [ {"abbr":"AL", "name":"Alabama"},
{"abbr":"AK", "name":"Alaska"}, {"abbr":"AZ", "name":"Arizona"}
//... ]});// Create the combo box, attached to the states data store
Ext.create('Ext.form.ComboBox', { fieldLabel: 'Choose State',
store: states, queryMode: 'local', displayField: 'name',
valueField: 'abbr', renderTo: Ext.getBody()});
var cb = Ext.create('Ext.form.ComboBox', { // all of your config options
listeners:{ scope: yourScope, 'select': yourFunction }});
// Alternatively, you can assign events after the object is created:
var cb = new Ext.form.field.ComboBox(yourOptions);
cb.on('select', yourFunction, yourScope);