博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ExtJs 4.2 treePanel
阅读量:6839 次
发布时间:2019-06-26

本文共 6947 字,大约阅读时间需要 23 分钟。

数据 只有第一个的

[  {    "id": "1",    "text": "Settings",    "children": [      {        "id": "5",        "text": "User settings",        "children": [          {            "id": "6",            "text": "Personal information",            "children": [              {                "id": "6_[view]",                "text": "[view]",                "children": [],                "checked": true,                "expanded": true,                "disabled": false              }            ],            "checked": true,            "expanded": true,            "disabled": false          },          {            "id": "7",            "text": "Change password",            "children": [              {                "id": "7_[view]",                "text": "[view]",                "children": [],                "checked": true,                "expanded": true,                "disabled": false              }            ],            "checked": true,            "expanded": true,            "disabled": false          },          {            "id": "8",            "text": "Login account management",            "children": [              {                "id": "8_[view]",                "text": "[view]",                "children": [],                "checked": true,                "expanded": true,                "disabled": false              }            ],            "checked": true,            "expanded": true,            "disabled": false          }        ],        "checked": true,        "expanded": true,        "disabled": false      },      {        "id": "12",        "text": "Transaction settings",        "children": [          {            "id": "13",            "text": "Access website",            "children": [              {                "id": "13_[view]",                "text": "[view]",                "children": [],                "checked": true,                "expanded": true,                "disabled": false              }            ],            "checked": true,            "expanded": true,            "disabled": false          },          {            "id": "14",            "text": "Trade password",            "children": [              {                "id": "14_[view]",                "text": "[view]",                "children": [],                "checked": true,                "expanded": true,                "disabled": false              }            ],            "checked": true,            "expanded": true,            "disabled": false          },          {            "id": "15",            "text": "Transaction certificate",            "children": [              {                "id": "15_[view]",                "text": "[view]",                "children": [],                "checked": true,                "expanded": true,                "disabled": false              }            ],            "checked": true,            "expanded": true,            "disabled": false          }        ],        "checked": true,        "expanded": true,        "disabled": false      }    ],    "checked": true,    "expanded": true,    "disabled": false  },

操作伸缩的代码

function CheckChild(node, checked) {        //选择所有子节点        node.eachChild(function (child) {            child.set("checked", checked);            CheckChild(child, checked);        });    }    //选择所有父节点    function CheckParent(node, checked) {        if (node.parentNode) {            if (checked == true) {                node.parentNode.set("checked", checked);                CheckParent(node.parentNode, checked)                return;            }            var ist = true;            node.parentNode.eachChild(function (child) {                if (child.get("checked") != false)                    ist = false;            });            if (ist) {                node.parentNode.set("checked", checked);                CheckParent(node.parentNode, checked)            }        }    }
var store = Ext.create('Ext.data.TreeStore', {                proxy: {                    type: 'ajax',                    url: "../Handler/MEEmployee.ashx?method=QUERYPERMISSION&MEMPLOYEEID=" + m_EmployeeID                },                root: {                    text: '<% = GetLocalResourceObject("AllPrivilegesText") %>',                    id: 'root',                    expanded: true,                    expandable: true,                    leaf: false                }            });            var tree = Ext.create('Ext.tree.Panel', {                store: store,                title: '<% = GetLocalResourceObject("PleasePermissionsText") %>',                id: "treePermission",                border: false,                renderTo: "dvPermission",                useArrows: true,                height: 205,                autoScroll: true,                animate: true,                enableDD: true,                containerScroll: true            });            tree.on('itemclick', function (view, record, item, index, event, eOpts) {                var expand = record.get('expanded')                if (expand) {                    view.collapse(record);                }                else {                    view.expand(record);                }                var checked = record.get("checked");                record.set("checked", !checked);                CheckChild(record, !checked);                CheckParent(record, !checked);            }, tree);            tree.getRootNode().expand();

传送id数据

function btnChange_OnClick() {                var arrParams = "";                var nodes = tree.getChecked();                for (var i = 0; i < nodes.length; i++) {                    var id = nodes[i].get("id");                    if (id != "root")                    arrParams += (',' + id);                }                //绑定界面数据                Ext.Ajax.request            ({                url: "../Handler/MEEmployee.ashx", //添加 url 具体在哪个页面实现编辑修改功能                params:                {                    "method": "EDITUSERPERMISSION",                    "USERID": m_EmployeeID,                    "USERPERMISSION": arrParams                },                success: function (respose, option) {                    var result = Ext.JSON.decode(respose.responseText);                    if (result.Flag) {                        Ext.Msg.alert('<% = GetLocalResourceObject("UpdateSuccessText") %>', '<% = GetLocalResourceObject("PromptText") %>', Window_OnClose);                                            }                    else {                        Ext.Msg.alert('<% = GetLocalResourceObject("FailText") %>', '<% = GetLocalResourceObject("SelectLessOneText") %>');                    }                },                failure: function () {                    //如果在服务器端处理数据发生了异常,就执行该函数的语句                    Ext.Msg.alert('<% = GetLocalResourceObject("WrongText") %>', '<%= GetGlobalResourceObject("GlobalResource","Systemerror")%>');                }            });            }

 

转载地址:http://remkl.baihongyu.com/

你可能感兴趣的文章
手机短信验证码真的安全吗?
查看>>
关于智慧城市建设的几点建议
查看>>
Facebook高管:我们是科技公司 不是媒体公司
查看>>
《领域特定语言》一2.3DSL的问题
查看>>
TensorFlow 1.0 正式发布 你需要知道的都在这里
查看>>
空调能窃听插座能放火?物联网成了“危”联网
查看>>
视频监控日常使用存在哪些故障
查看>>
半导体并购停不下来 ADI拟148亿美元收购Linear
查看>>
高通的专利霸权要到头了?
查看>>
工信部:推动窄带物联网、5G泛在信息基础设施
查看>>
市场与需求带动 向智能安放转型成大势所趋
查看>>
云时代看CRM如何引领企业成功?
查看>>
物联网帝国——孙正义职业生涯最大的豪赌
查看>>
互联网时代大数据的核心价值
查看>>
安全报告显示2015年DDoS攻击强度创下新纪录
查看>>
智慧城市“双引擎”:城市创新活力与市民宜居体验
查看>>
外汇呼叫中心如何在严格监管中存续
查看>>
安全攻防之SQL注入
查看>>
OssImport系列之四——最佳实践
查看>>
BurpSuite实例教程讲解
查看>>