Extjs 4.2 comboBox下拉复选框 checkbox

来源:互联网 发布:枪林弹雨刷永久枪软件 编辑:程序博客网 时间:2024/04/29 02:22
    Ext.create('Ext.form.field.ComboBox',{          name : 'cmb',          fieldLabel : '人员',          margin:'2 0 2 0',          labelWidth : 135,          labelAlign : 'right',          editable : false,          allowBlank : false,          multiSelect : true,          store : {              fields : ['personId', 'personName'],              data : [                  {'personId':'0',personName:'张三'},                  {'personId':'1',personName:'李四'},                  {'personId':'2',personName:'王五'},                  {'personId':'3',personName:'小名'}              ]          },          listConfig : {              itemTpl : Ext.create('Ext.XTemplate','<input type=checkbox>{[values.personName]}'),              onItemSelect : function(record) {                  var node = this.getNode(record);                  if (node) {                      Ext.fly(node).addCls(this.selectedItemCls);                      var checkboxs = node.getElementsByTagName("input");                      if (checkboxs != null)                          var checkbox = checkboxs[0];                      checkbox.checked = true;                  }              },              listeners : {                  itemclick : function(view, record, item, index, e, eOpts) {                      var isSelected = view.isSelected(item);                      var checkboxs = item.getElementsByTagName("input");                      if (checkboxs != null) {                          var checkbox = checkboxs[0];                          if (!isSelected) {                              checkbox.checked = true;                          } else {                              checkbox.checked = false;                          }                      }                  }              }          },          queryMode : 'local',          displayField : 'personName',          valueField : 'personId',          renderTo : Ext.getBody()      });  

效果图:


0 0