Dojo TreeGrid 懒加载
2015-01-20 11:02
197 查看
JS
dojo.require("dojox.grid.TreeGrid"); dojo.require("dijit.tree.ForestStoreModel"); dojo.require("dojox.data.JsonRestStore"); dojo.require("dijit.form.Button"); dojo.require("dojo.parser"); jsonStore = null, childItems = null, dataItems = null, fullItems = null; dojo.addOnLoad(function() { childItems = { 'AF' : [ { id : 'EG', name : 'Egypt', type : 'country' }, { id : 'KE', name : 'Kenya', type : 'country' }, { id : 'SD', name : 'Sudan', type : 'country' } ], 'KE' : [ { id : 'Nairobi', name : 'Nairobi', type : 'city' }, { id : 'Mombasa', name : 'Mombasa', type : 'city' } ], 'SD' : [ { id : 'Khartoum', name : 'Khartoum', type : 'city' } ], 'AS' : [ { id : 'CN', name : 'China', type : 'country' }, { id : 'IN', name : 'India', type : 'country' }, { id : 'RU', name : 'Russia', type : 'country' }, { id : 'MN', name : 'Mongolia', type : 'country' } ], 'OC' : [ { id : 'AU', name : 'Australia', type : 'country', population : '21 million' } ], 'EU' : [ { id : 'DE', name : 'Germany', type : 'country' }, { id : 'FR', name : 'France', type : 'country' }, { id : 'ES', name : 'Spain', type : 'country' }, { id : 'IT', name : 'Italy', type : 'country' } ] }; dataItems = [ { id : 'AF', name : 'Africa', type : 'continent', population : '900 million', area : '30,221,532 sq km', timezone : '-1 UTC to +4 UTC', children : true, '$ref' : 'AF' }, { id : 'AS', name : 'Asia', type : 'continent', children : true, '$ref' : 'AS' }, { id : 'OC', name : 'Oceania', type : 'continent', population : '21 million', children : true, '$ref' : 'OC' }, { id : 'EU', name : 'Europe', type : 'continent', children : true, '$ref' : 'EU' } ]; fullItems = {}; dojo.forEach(dataItems, function(item) { var full = fullItems[item.id] = dojo.mixin({}, item, { children : childItems[item.id] }); delete full['$ref']; }); var mockService = function(query) { var d = new dojo.Deferred(); if (typeof query == 'string') { setTimeout(function() { d.callback(fullItems[query]); }, 500); } else { d.fullLength = dataItems.length; d.callback(dataItems); } return d; }; jsonStore = new dojox.data.JsonRestStore({ service : mockService, target : '/some/url' }); dojo.parser.parse(); });HTML
<body class="tundra"> <h1 class="testTitle">Test: dojox.grid.TreeGrid - Model-based lazy loading</h1> <div dojoType="dijit.tree.ForestStoreModel" data-dojo-id="continentModel" store="jsonStore" query="{type:'continent'}" deferItemLoadingUntilExpand="true" rootId="continentRoot" rootLabel="Continents" childrenAttrs="children"> </div> <h4 class="testSubtitle">dojox.grid.TreeGrid n-Level</h4> <table data-dojo-id="grid" dojoType="dojox.grid.TreeGrid" class="grid" treeModel="continentModel"> <thead> <tr> <th field="name" width="auto">Name</th> </tr> </thead> </table> </body>效果图
相关文章推荐
- EASYUI TREEGRID异步加载数据实现方法
- easyui treegrid逐步加载
- gridPanel treePanel 预加载动作
- easyui treegrid 调webservice实现异步加载
- Dojo Dijit.Tree 懒加载
- easyui treegrid逐步加载
- EASYUI TREEGRID异步加载数据实现方法
- jqgrid treegrid 重新加载数据
- 可否实现Ext.ux.maximgb.TreeGrid的动态加载吗
- easyUI treeGrid 惰性加载,动态加载,无论有无子节点都显示展开图标
- Jquery EasyUI TreeGrid 一次性加载数据,递归
- easyui treegrid动态加载节点
- easyui tree/TreeGrid使用:逐级加载、指定节点刷新、全部展开
- easyui treegrid 封装(不用分页,用加载更多按钮)延迟加载加加载更多
- easyui treegrid 懒加载
- easyui treegrid 封装(不用分页,用加载更多按钮)延迟加载加加载更多
- 蛋疼的EASYUI TREEGRID异步加载数据
- Jquery EasyUI TreeGrid异步加载
- SSH+Ext左侧tree右侧grid,点击左侧tree节点右侧grid数据动态加载和分页问题
- easyui treegrid 封装(不用分页,用加载更多按钮)延迟加载加加载更多