`
lbyzx123
  • 浏览: 466779 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

ExtJS树型下拉框

阅读更多

/**
 * @type String
 * @description 员工树型下拉框
 */
//-----定义userComboBox对象的expand事件所需要的TreePanel------
var userTree=function(combo){
 userTree.superclass.constructor.call(this,{
  id : 'deptTree',
  animate : true,
  enableDD : false,
  rootVisible : false,
  border:false,
  root : new Ext.tree.AsyncTreeNode({
     expanded : false,
     text : '组织结构'
    }),
  loader :tl=new Ext.tree.TreeLoader({
    url : 'sysuserpoweraction.do?option=getAll'
   }),
  listeners:{"click":function(node,event){
   var val=node.id;
   if(val.indexOf('dep')<0){//判断叶子节点为部门时,不允许选择
    if(node.leaf){//员工为叶子时,给combo、userId赋值
     combo.setValue(node.text);
     Ext.getCmp('userId').setValue(node.id);    
     combo.collapse();
    }else{
     node.toggle();
    }
   }   
  }}
 });
};
Ext.extend(userTree, Ext.tree.TreePanel);//userTree继承Ext.tree.TreePanel
//-----定义树型下拉框类-----------------
 var userComboBox=function(label,wid,eText,bText){
  var user=this;  
 userComboBox.superclass.constructor.call(this,{  
  id:'userCombo',  
  isFormField: true,
        valueField: "value",
        displayField: "text",
        fieldLabel:label,
        emptyText: eText,
        width: wid,
        store :new Ext.data.SimpleStore({
     fields : [],
     data : [[]]
    }),
        editable: false,
        allowBlank: false,
        blankText:bText,
        mode: 'local',
        triggerAction: 'all',
        tpl : "<tpl for='.'><div style='height:200px'><div id='deptUser'></div><div></tpl>",
        listeners:{"expand":function(){         
          (new userTree(user)).render('deptUser');
         },"collapse":function(){
          document.getElementById('deptUser').innerHTML="";
         }
           }                
        }); 
};
Ext.extend(userComboBox, Ext.form.ComboBox);//userComboBox继承Ext.form.ComboBox

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics