Ext.Tree扩展CheckBox方法

/引入这个JS:    Ext.ux.tree.TreeCheckNodeUI.js

//

//业务品类(类别TYPE)
            layout : 'tableform',
            border : false,
            items : [{
                xtype : 'textfield',
                fieldLabel : '业务品类',
                readOnly : (customFields_id != null && customFields_id != "") ? true : false,
                name : 'TYPE',
                id : 'customfields_type_id',
                readOnly : true,
                width : 350
            }, {
                xtype : 'button',
                text : '选择',
                style : 'margin-left:10px;',
                disabled : (customFields_id != null && customFields_id != "") ? true : false,
                id : 'btnSelect',
                handler : customfields_build_SelectBusinessCategory
            }]

 

 

  //↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓选择业务品类 region↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

    /**
     * 新建自定义自段 选择业务品类
     */
    function customfields_build_SelectBusinessCategory() {
        var departmentIDArr = new Array();
        Array.prototype.contains = function(element) {
            for (var i = 0; i < this.length; i++) {
                if (this[i] == element) {
                    return true;
                }
            }
            return false;
        }

        var checkIDS = setting_customfieldsbuild_form.getForm().findField('category_id').getValue();
        if (checkIDS != "" && checkIDS != null) {
            departmentIDArr = checkIDS.split(',');
        }

        function workflow_build_checkEachChildNode(treeNode) {
            var childLength = treeNode.childNodes.length;
            for (var i = 0; i < treeNode.childNodes.length; i++) {
                if (departmentIDArr.contains(treeNode.childNodes[i].id)) {
                    treeNode.childNodes[i].attributes.checked = true;//.select();//.checked=true;//toggleCheck(true);
                    if (!treeNode.childNodes[i].leaf) {
                        workflow_build_checkEachChildNode(treeNode.childNodes[i]);
                    }
                }
            }
        }
        Ext.getCmp('btnSelect').disable();
        var setting_customfield_BusinessCategory_treePanel = new Ext.tree.TreePanel({
            lines : true,
            containerScroll : true,
            autoScroll : true,
            //checkModel : 'single',
            checkModel : 'cascade',// 对树的级联多选  
            onlyLeafCheckable : false,//对树所有结点都可选  
            loader : new Ext.tree.TreeLoader({
                dataUrl : 'BLL/ModuleSystem/Setting/BusinessCategory/Operation.aspx?cmd=businessCategoryTree&rand=' + Math.round(Math.random() * (10000 - 1)).toString(),
                baseAttrs : {
                    uiProvider : Ext.tree.TreeCheckNodeUI
                }
            }),
            root : new Ext.tree.AsyncTreeNode({
                id : "root2",
                text : "选择业务品类",
                expanded : true
            })
        });
        if (checkIDS != "" && checkIDS != null) {
            setting_customfield_BusinessCategory_treePanel.expandAll();
        }
        setting_customfield_BusinessCategory_treePanel.on('load', workflow_build_checkEachChildNode);
        var setting_customfield_BusinessCategory_Form = new Ext.form.FormPanel({
            layout : 'form',
            labelAlign : 'top',
            layout : 'fit',
            bodyStyle : 'padding:20px',
            width : 400,
            labelWidth : 70,
            labelAlign : "right",
            autoScroll : true,
            items : [setting_customfield_BusinessCategory_treePanel],
            buttons : [{
                text : "选择",
                handler : function() {
                    var checkedNodes = setting_customfield_BusinessCategory_treePanel.getChecked();
                    var checkText = new Array;
                    var checkId = new Array;// 存放选中id的数组
                    for (var i = 0; i < checkedNodes.length; i++) {
                        checkText.push(checkedNodes[i].text);// 添加id到数组
                        checkId.push(checkedNodes[i].id);
                    }
                    var value = checkText.toString().replace(/\,/g, ';');
                    setting_customfieldsbuild_form.getForm().findField('TYPE').setValue(value);
                    setting_customfieldsbuild_form.getForm().findField('category_id').setValue(checkId.toString());
//                    Ext.getCmp('customfields_type_id').setValue(value);
//                    Ext.getCmp('businesscategory_id_hidden').setValue(checkId.toString());
                    Ext.getCmp('btnSelect').enable();
                    customfields_build_BusinessCategoryWin.close();
                }
            }, {
                text : "取消",
                handler : function() {
                    Ext.getCmp('btnSelect').enable();
                    customfields_build_BusinessCategoryWin.close();
                }
            }]
        });
        var customfields_build_BusinessCategoryWin = new Ext.Window({
            title : "选择业务品类",
            layout : 'fit',
            width : 400,
            height : 300,
            closeAction : 'destroy',
            autoScroll : true,
            plain : true,
            resizable : false,
            constrainHeader : true,
            items : setting_customfield_BusinessCategory_Form,
            listeners : {
                'beforedestroy' : function(p) {
                    Ext.getCmp('btnSelect').enable();
                }
            }
        });
        customfields_build_BusinessCategoryWin.show();
    }
    //↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑选择业务品类 endregion↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值