Ext 树形的下拉框

将下面代码直接复制到相应的位置就可看效果
var comboxWithTree = new Ext.form.ComboBox({  
            fieldLabel:"使用科室",
            hiddenName:'entity.cuseDept',
            store:new Ext.data.SimpleStore({fields:[],data:[[]]}),  
            editable:false,  
            mode: 'local',  
            triggerAction:'all',  
            maxHeight: 200,  
            tpl: "<tpl for='.'><div style='height:200px'><div id='tree'></div></div></tpl>",  
            selectedClass:'',  
            onSelect:Ext.emptyFn  
        }); 
      
        var tree = new Ext.tree.TreePanel({
            containerScroll: true,//是否支持滚动条
            rootVisible:false,//是否显示跟节点
            loader:new Ext.tree.TreeLoader({
                dataUrl:'base/department!getTree.action'
            }) ,
            root:new Ext.tree.AsyncTreeNode({
                text:'root',
                draggable:false,//是否可以拖拽
                id:'-1'
            })
        });
       
        tree.on('click',function(node){  
              comboxWithTree.setValue(node.text);  
              comboxWithTree.collapse();  
        });  
        comboxWithTree.on('expand',function(){  
            tree.render('tree');  
        });  


你可能感兴趣的:(ext)