Extjs6.2 中form中ComboBox组件的使用

时间:2022-02-18 18:39:45
Ext.create('Ext.form.ComboBox', {
fieldLabel: '所属组织',
emptyText : '请选择',
name: 'group',
width: '100%',
/** 必须选择一个选项 **/
forceSelection : true,
/** 该项如果没有选择,则提示错误信息 **/
blankText : '请选择',
allowBlank: false,
store: Ext.create('Ext.data.Store',{
fields:['id','name'],
proxy: {
type: 'ajax',
url: 'getGroupList.html',
reader: {
type: 'json',
rootProperty: 'data'
}
},
autoLoad: true
}),
queryMode: 'local',
displayField: 'name',
valueField: 'id',
listeners: {
/** 捕获鼠标离开combo的text **/
blur: function(combo){
var comboText = combo.lastQuery;
console.dir("combo离开后的text: "+comboText);
},
/** 捕获键盘上次输入combo的text **/
beforequery: function(e) {
var comboText = e.combo.lastQuery;
console.dir("combo输入新内容时的text: "+comboText);
}
}
});