EXT 下拉树形(tree)列表


最终要获取的是部门的ID号。方法:
点击下拉框的时候触发事件,使树形目录展开,
点击部门时将获取的值赋给相应的表单项目


//新建用户下拉列表。
var user_combobox = new Ext.form.ComboBox({
    store:            new Ext.data.SimpleStore({fields:[],data:[[]]}),
    id:                'person_combobox',
    //hiddenName:        'parent_group',
    readOnly:        true,
    editable:false, //禁止手写及联想功能
    fieldLabel:     '所属部门',
    emptyText:         '请选择部门',
    blankText:        '请选择用户所属部门',
    allowBlank:        false,
    validateOnBlur:    true,
    mode:             'local',
    triggerAction:    'all',
    anchor:            '90%',
    tpl:             '<div id="user_group_tree " style="height:200px"></div>',
    resizable:        true
});


//下拉列表树形结构
var user_tree = new Ext.tree.TreePanel({
    border:false,
    autoScroll:true,
    animate:true,
    autoWidth:true,
    autoHeight:true,
    enableDD:false,
    containerScroll: true,
    loader: new Ext.tree.TreeLoader({
        dataUrl:'tree/modules/combobox.php'            
    })
});

//树的点击事件
user_tree.on("click",function(node,e)
{      
        Ext.get('parent_id').dom.value = node.id;//一个隐藏的表单项
        user_combobox.setValue(node.text);//设置option值
        user_combobox.collapse();//隐藏option列表
});

var user_root = new Ext.tree.AsyncTreeNode({
        text: '安一软件公司',                  //节点名称
        draggable:false,    
        icon:'images/icon/org.gif',             //是否支持拖动
        id:'asindata'                      //节点id
});

user_tree.setRootNode(user_root);
//展开option时生成树
user_combobox.on('expand',function(){
user_tree.render('user_group_tree');
user_tree.expandAll();//自动展开树
});

tree/modules/combobox.php产生的结果如下:

[{'id' : '134','text' : '134-right','parent_id' : '1','description' : '111111','str_type' : 'dept','icon'
 : 'images/icon/depart.gif','children':[]}
,{'id' : '135','text' : '135-offline','parent_id' : '1','description'
 : '111111','str_type' : 'dept','icon' : 'images/icon/depart.gif','children':[]}
,{'id' : '136','text'
 : '136','parent_id' : '1','description' : 'asindata','str_type' : 'dept','icon' : 'images/icon/depart
.gif','children':[]}
,{'id' : '138','text' : '138','parent_id' : '1','description' : '','str_type' : 'dept'
,'icon' : 'images/icon/depart.gif','children':[]}
,{'id' : '139','text' : 'asindata','parent_id' : '1'
,'description' : 'asindata','str_type' : 'dept','icon' : 'images/icon/depart.gif','children':[]}
]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值