extjs4 combobox 多选与赋值 2017.1.10

来源:互联网 发布:球员对比的软件 编辑:程序博客网 时间:2024/06/11 04:43

初始化

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");                });            }        }    }}

如果你的问题还是没有解决,欢迎留言

0 0