我有一个dgrid,使用树列插件。每次用户点击树时,我都会调用服务器,捕获子(json)并绑定它。但是当它发生时,这些子行显示在错误的位置,如图像波纹管。最奇怪的是当我改变分页时,回到第一页后,子行保持在正确的位置。
(请告诉我是否可以理解我的英语,然后我可以尝试改进文本)
我的dgrid代码:
var CustomGrid = declare([OnDemandGrid, Keyboard, Selection, Pagination]);
var grid = new CustomGrid({
columns: [
selector({label: "#", disabled: function(object){ return object.type == 'DOCx'; }}, "radio"),
{label:'Id', field:'id', sortable: false},
tree({label: "Title", field:"title", sortable: true, indentWidth:20, allowDuplicates:true}),
//{label:'Title', field:'title', sortable: false},
{label:'Count', field:'count', sortable: false}
],
store: this.memoryStore,
collapseOnRefresh:true,
pagingLinks: false,
pagingTextBox: true,
firstLastArrows: true,
pageSizeOptions: [10, 15, 25],
selectionMode: "single", // for Selection; only select a single row at a time
cellNavigation: false // for Keyboard; allow only row-level keyboard navigation
}, "grid");
我的记忆库:
loadMemoryStore: function(items){
this.memoryStore = Observable(new Memory({
data: items,
getChildren: function(parent, options){
return this.query({parent: parent.id}, options);
},
mayHaveChildren: function(parent){
return (parent.count != 0) && (parent.type != 'DOC');
}
}));
},
这一刻我绑定了子行:
success: function(data){
for(var i=0; i<data.report.length; i++){
this.memoryStore.put({id:data.report[i].id, title:data.report[i].created, type:'DOC', parent:this.designId});
}
},
我在思考,也许每一刻我都会绑定子行,我可以像在网格上刷新一样,也许是有效的。我认为分页也是一样的。
感谢。
编辑:
我忘记了这个问题。那么,我该如何纠正这个错误呢?如果dgrid中的刷新有效。我该怎么做?我想的其他事情,也许我的getChildren是错的,但我无法识别它。
再次感谢。答案 0 :(得分:3)
我的解决方案是从PARENT hierarquia改为CHILDREN hierarquia。现在工作正常。
我的dgrid代码:
this.mapReportItems(reportDAO.get());
//this.mapReportItems(x);
this.loadMemoryStore(this.reportItems);
var CustomGrid = declare([OnDemandGrid, Keyboard, Selection, Pagination]);
var grid = new CustomGrid({
columns: [
selector({label: "#", disabled: function(object){ return object.type == 'DOCx'; }}, "radio"),
{label:'Id', field:'id', sortable: false},
tree({label: "Title", field:"title", sortable: false, indentWidth:20, shouldExpand:function() { return 0; }}),
//{label:'Title', field:'title', sortable: false},
{label:'Count', field:'count', sortable: true}
],
query: {parent: parent.children },
store: this.memoryStore,
deselectOnRefresh: false,
//columnReordering:true,
collapseOnRefresh:false,
pagingLinks: false,
pagingTextBox: true,
firstLastArrows: true,
pageSizeOptions: [10, 15, 25],
selectionMode: "single", // for Selection; only select a single row at a time
cellNavigation: false // for Keyboard; allow only row-level keyboard navigation
}, "grid");
我的记忆库:
this.memoryStore = Observable(new Memory({ 数据:项目, getChildren:function(parent){
return parent.children;
},
mayHaveChildren: function(parent){
//return (parent.count != 0) && (parent.type != 'DOC');
return (parent.children && parent.children.length) || (parent.count != 0 && parent.type != 'DOC');
}
}));
这一刻我绑定了子行:
success: function(data){
var node = this.memoryStore.get(this.designId);
for(var i=0; i<data.report.length; i++){
node.children.push({id:data.report[i].id, title:data.report[i].created, type:'DOC'});
}
this.memoryStore.put(node);
this.data = data;
},
额外信息。在我的情况下,我需要以这种方式映射我的Json数据:
this.reportItems = dojo.map(jsondata.reportDesign, function(report) {
return {
//'@uri': report[1],
id : report.id,
title : report.title,
count : report.count,
children: [],//report.children,
type : report.type
//parent : report.parent
};
});