Admin1945
踩坑的小菜鸟
2017-07-05 07:37

ExtJs动态加载二级树无限循环怎么办?

  • extjs

如题,下面是我返回的JSon:
{
"bugs": [
{
"id": 1,
"text": "用户管理",
"leaf": false,
"children": [
{
"id": 7,
"text": "修改用户",
"leaf": true,
"attributes": {
"url": "UserManager.html"
}
},
{
"id": 8,
"text": "添加用户",
"leaf": true,
"attributes": {
"url": "UserManager.html"
}
},
{
"id": 9,
"text": "删除用户",
"leaf": true,
"attributes": {
"url": "UserManager.html"
}
}
]
},
{
"id": 2,
"text": "职务管理",
"leaf": false,
"children": [
{
"id": 10,
"text": "修改职务",
"leaf": true,
"attributes": {
"url": "DepartManager.html"
}
},
{
"id": 11,
"text": "添加职务",
"leaf": true,
"attributes": {
"url": "DepartManager.html"
}
},
{
"id": 12,
"text": "删除职务",
"leaf": true,
"attributes": {
"url": "DepartManager.html"
}
}
]
},
{
"id": 6,
"text": "商品管理",
"leaf": false,
"children": [
{
"id": 3,
"text": "商品出库审批",
"leaf": true,
"attributes": {
"url": "GoodsManager.html"
}
},
{
"id": 4,
"text": "商品入库审批",
"leaf": true,
"attributes": {
"url": "GoodsManager.html"
}
},
{
"id": 13,
"text": "添加商品入库",
"leaf": true,
"attributes": {
"url": "GoodsManager.html"
}
},
{
"id": 14,
"text": "商品入库审批",
"leaf": true,
"attributes": {
"url": "GoodsManager.html"
}
},
{
"id": 15,
"text": "添加商品出库",
"leaf": true,
"attributes": {
"url": "GoodsManager.html"
}
},
{
"id": 16,
"text": "商品出库审批",
"leaf": true,
"attributes": {
"url": "GoodsManager.html"
}
}
]
},
{
"id": 17,
"text": "授权管理",
"leaf": false,
"children": [
{
"id": 22,
"text": "授权",
"leaf": true,
"attributes": {
"url": "GoodsManager.html"
}
}
]
}
]
}
这是我的页面:
Ext.onReady(function () {
var tree_store = Ext.create('Ext.data.TreeStore', {
id: 'tree_store',
proxy: {
type: 'ajax',
url: 'Home/TreeDate',
reader: {
type: 'json',
root: 'bugs'
}
},
root: {
text: '部门',
expanded:true
},
autoLoad:true
});
var left = Ext.create('Ext.tree.Panel', {
renderTo:Ext.getBody(),
title: "菜单",
width: 200,
store: tree_store,
border: true
})
})

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐

换一换