0

我有一个基于服务器数据动态生成的树面板。下面是生成树面板并将其添加到表单的代码。

Ext.Ajax.request({
    url: '../Get_Menu.php',
    method: 'POST',
    success: function (result, request) {
        var json = result.responseText;
        var temp = Ext.decode(json);
        var obj = {};
        var item = {};
        var menu = {};
        var children = [];
        var module = [{
            "text": "Administrator",
                "leaf": true,
                "checked": false,
                "id": "GROUP_ADMIN",
                "formBind": true,
                "name": "GROUP_ADMIN"
        }];

        for (var i = 0; i < Object.keys(temp.MENUS).length; i++) {

            for (var key in temp.MENUS[i]) {

                for (var n = 0; n < Object.keys(temp.MENUS[i][key]).length; n++) {

                    item = {
                        "text": temp.MENUS[i][key][n],
                            "checked": false,
                            "id": key + "_" + temp.MENUS[i][key][n],
                            "name": key + "_" + temp.MENUS[i][key][n],
                            "formBind": true,
                            "leaf": true
                    };
                    children.push(item);
                }
                menu = {
                    "text": key,
                        "leaf": false,
                        "id": key,
                        "children": children
                };

                module.push(menu);
                children = [];
            }
        }
        obj = {
            "text": "Service Quality",
                "expanded": true,
                "formBind": true,
                "children": module
        };

        Ext.getCmp('permissionsTreePanel').setRootNode(obj);

    },
    failure: function (result, request) {
        Ext.Msg.alert('Error', 'An Error occured...');
    }
});

我必须根据收到的服务器数据检查树面板的节点,如下所示:

{"PERMISSIONS":{"GROUP_ADMIN":"false","OPERATIONS_MSU":"true","OPERATIONS_SCHEDULE":"false","OPERATIONS_MARKET_DASHBOARD":"false","OPERATIONS_FE_REFERENCE":"true","PRODUCTION_QUICKQC_VOICE":"false","PRODUCTION_QUICKQC_DATA":"false","PRODUCTION_MARKETQC_VOICE":"false","PRODUCTION_MARKETQC_DATA":"false","PRODUCTION_SURGERY":"false","PRODUCTION_FILE_INVENTORY":"false","PRODUCTION_MARKET_TRACKER":"false","PRODUCTION_DRIVE_ROUTE_TRACKER":"false","PRODUCTION_TICKETS":"false","PRODUCTION_ASSETS":"false","MANAGEMENT_DAILY_STATUS":"false","MANAGEMENT_DAILY_PROCESSING":"false","MANAGEMENT_WEEKLY_WORKFLOW":"false","MANAGEMENT_CUSTOMER_QUESTIONS":"false","MANAGEMENT_KPI_PERFORMANCE_METRICS":"false","MANAGEMENT_COLLECTION_METRICS":"false","MANAGEMENT_OPERATIONS_DASHBOARD":"false","MANAGEMENT_PRODUCTION_DASHBOARD":"false","MANAGEMENT_SUPPORT_DASHBOARD":"false","MANAGEMENT_REVENUE_TRACKER":"false","MANAGEMENT_DEPLOYMENT_TRACKER":"false","SUPPORT_TICKETS":"false","SUPPORT_ASSET_MANAGEMENT":"false","SUPPORT_GENERATE_SHIPMENT":"false","TRAINING_RESOURCES":"false","TRAINING_SCHEDULE":"false"}}

树面板: 在此处输入图像描述

请帮助我通过服务器数据检查树面板节点。

帮助将不胜感激!

非常感谢 :)

4

1 回答 1

2

你不能在服务器端设置权限吗?

无论如何,您可以使用“权限”请求中的成功回调。您可以遍历权限,然后按 Id 获取树节点:

var treepanel = Ext.getCmp('permissionsTreePanel');
var treestore = treepanel.getStore();
var node = treestore.getNodeById('GROUP_ADMIN'); //current permission key
node.set('checked', true); // current permission value
于 2013-08-01T14:07:40.300 回答