extjs4 combobox 多選與賦值 2017.1.10
阿新 • • 發佈:2019-01-01
初始化
xtype: 'combobox',
editable: false,
multiSelect: true,//啟用多選
queryModel: 'local',
displayField: 'text',
valueField: 'id',
store: Store
多選賦值,陣列
combobox.setValue([0,1]);
combobox.setValue(['值1','值2']);
注意
Ext.define('TEST', {
extend: 'Ext.data.Model',
//fields: ['id','text'],
//數字或字串要一致,不然賦值不上
fields: [{name:'id',type:'string'},'text']
});
下拉聯動進行過濾
listeners: {
'change': function(field,newValue,oldValue,epots){
if (newValue != oldValue) {
if(Store.data.length == 0 || field.getRawValue()==''){
Store.clearFilter();
}else{
Store.filterBy(function (item) {
return newValue.length>1?Ext.Array.contains(newValue, String(item.get("pid"))):newValue[0]==item.get("pid");
});
}
}
}
}
如果你的問題還是沒有解決,歡迎留言