Extjs TreeStore无限制加载数据的问题

Ext.define('myKaiDun.model.sys.MenusModel', {
    extend : 'Ext.data.TreeModel',
    fields : [ 'id', 'text', 'leaf', 'url', 'expanded', 'children', 'menu' ]
});
Ext.create('Ext.data.TreeStore', {
                            defaultRootId : '0',
                            autoLoad : false,
                            autoSync : false,
                            model : 'myKaiDun.model.sys.MenusModel',
                            proxy : {
                                type : 'ajax',
                                extraParams : {
                                    'id' : rec.get('id')
                                },
                                url : 'menuAction_menusRoleId.action',
                                reader : {
                                    type : 'json',
                                    root:'treeNodes'
                                }
                            }
                        });

由于本人想一次性加载所以不想异步加载,本人后台用的是struts2 但是后台我设置了

<result name="menusRoleId" type="json">
                <param name="root">treeNodes</param>
 </result>

会发现treeStore还是会无限制的加载下去 无非就是加载已经重复的数据 调用的还是我第一次加载数据的方法 直接把
reader : {
type : ‘json’,
root:’treeNodes’
}
root:’treeNodes’去掉就好了

发布了32 篇原创文章 · 获赞 4 · 访问量 5万+
展开阅读全文

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

07-05

如题,下面是我返回的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 }) }) 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览