我在ExtJS 4.2中遇到了同样的问题,我尝试通过以下代码来解决这个问题。
Ext.define('XZSoftware.view.sysconfig.permission.PermissionWindow', {
extend: 'Ext.window.Window',
itemid: "sysconfig-permission-window",
vierConfig: { loadMask: true },
layout:
{
type: "fit"
},
minWidth: 400,
minHeight: 300,
tree: null,
treeStore: null,
initComponent: function () {
var me = this;
Ext.log("initComponent()", me);
me.treeStore = Ext.create("Ext.data.TreeStore", {
proxy: {
type: "ajax",
actionMethods: { read: "POST" },
reader: {
type: "json",
root: "data"
},
url: '/permissiontree_load.xzsoftware?o=AAAAACB'
},
root: {
text: "Premission Tree",
expanded: true
}
});
me.tree = Ext.create("Ext.tree.Panel", {
rootVisible: false,
store: me.treeStore
});
me.items = [
me.tree
];
this.callParent(arguments);
},
Version: "1.0.0.0"
});
JSON 将从 HTTP 请求中响应。
{
"total": 17,
"data": [{
"data": [{
"data": [],
"expanded": true,
"leaf": "true",
"checked": false,
"text": "HSBC"
}, {
"data": [],
"expanded": true,
"leaf": "true",
"checked": false,
"text": "All IDoc"
}, {
"data": [],
"expanded": true,
"leaf": "true",
"checked": false,
"text": "ProCRM"
}],
"expanded": true,
"leaf": "false",
"checked": false,
"text": "Application Portal"
}, {
"data": [{
"data": [],
"expanded": true,
"leaf": "true",
"checked": false,
"text": "Order List"
}, {
"data": [{
"data": [],
"expanded": true,
"leaf": "true",
"checked": false,
"text": "Report by monthly total"
}],
"expanded": true,
"leaf": "true",
"checked": false,
"text": "Order Report"
}, {
"data": [],
"expanded": true,
"leaf": "true",
"checked": false,
"text": "Search"
}],
"expanded": true,
"leaf": "false",
"checked": false,
"text": "CNMOT - OMS"
}, {
"data": [{
"data": [],
"expanded": true,
"leaf": "true",
"checked": false,
"text": "Company"
}, {
"data": [],
"expanded": true,
"leaf": "true",
"checked": false,
"text": "Funcation Setting"
}, {
"data": [],
"expanded": true,
"leaf": "true",
"checked": false,
"text": "Menu Setting"
}, {
"data": [],
"expanded": true,
"leaf": "true",
"checked": false,
"text": "Page Setting"
}, {
"data": [],
"expanded": true,
"leaf": "true",
"checked": false,
"text": "Permission"
}, {
"data": [],
"expanded": true,
"leaf": "true",
"checked": false,
"text": "Roles"
}, {
"data": [],
"expanded": true,
"leaf": "true",
"checked": false,
"text": "Users"
}],
"expanded": true,
"leaf": "false",
"checked": false,
"text": "System Setting"
}],
"success": true,
"message": "Success"
}
注释:
1.应在TreeStore中设置根配置。
2.JSON数据中的“children”字段需更改为store代理中的根配置。在我的示例中,“children”设置为“data”。