我们如何在dojo树网格中设置孩子
How can we set children in dojo TreeGrid?
当我使用LazyTreeGrid
时,我遇到了一个小问题;我有这样的JSON文件:
{id: 'AF', name:'Africa',description:""},
{id: 'EG', name:'Egypt',description:""},
{id: 'KE', name:'Kenya',description:
{
compents:
[
{id: 'Nairobi', name:'Nairobi', type:'city'},
{id: 'Mombasa', name:'Mombasa', type:'city'}
]
}
}
我不知道如何在ForestStoreModel
中设置子项,也许像childrenAttrs:['description.compents']
一样(不幸的是,它不起作用…)?
我找到了一个解决方案,我们可以像这个一样使用onComplete
var model = new ForestStoreModel( {
getChildren : function ( item, onComplete, onError ) {
onComplete( item.dataDescription.components );
}
} );
这对我来说很好。
我在Json文件和普通lazyloading树上也遇到了同样的问题。
为了得到孩子们,我像这样做了
var restStore = new JsonRest
({
target: "http://localhost........",
headers: { 'Content-Type': 'application/json;charset=utf-8' }
});
// Get an object by identity, then the remaining code will be executed (because of the async)
// Otherwise the remaining code will be executed, before we get the object from the server (it wouldn't work)
restStore.get("").then(function(items)
{
// set up a local store to get the tree data, plus define the method
// to query the children of a node
var MemoryStore = new Memory
({
data: items,
getChildren: function(object)
{
return this.query({parent: object.id});
}
});
我不知道你是否必须从另一台服务器上获取json文件,但也许它也能类似地工作!
问候,
Alex
相关文章:
- 如何在剑道网格初始化后设置pageSizes
- 如何在可分组的剑道网格中设置空数据文本
- 在有角度的ui网格中设置动态列的问题
- 如何在three.js中设置网格绘制的动画
- 在网格视图的自动刷新过程中,设置内部网格视图文本框的可见性
- 如何在javascript中设置网格组合框值
- 回调以设置postdata,而无需重新加载网格
- 在Kendo UI中将网格pageSize设置为变量
- 在剑道网格中,我可以用一个函数动态设置列属性吗
- 无论网格中有多少单词,都要设置网格集大小
- 设置新网格行的动画
- 我们如何在dojo树网格中设置孩子
- 将列设置为在EasyUI数据网格上按排序显示
- 无法设置属性'网格'的未定义
- 如何在后台网格中将特定的可编辑单元格设置为不可编辑
- UI 网格设置列顺序
- 在 Dojo 增强网格筛选器栏上设置状态文本
- 当网格视图设置为 true 时,Jqgrid 在 IE9 中显示“正在加载”
- Dojo 数据网格:设置有条件的可编辑列(在运行时更改)
- 如何从子网格设置默认表单