我是 JavaScript、dojo dgrid、dstore 的初学者,但仍然很难正确覆盖商店的属性方法:
我的数据结构:
[{"id":"T1","name":"Test","desc":"Rectangular 1",qty":null,"parent":null},
{"id":"C1","name":"Test 2","qty":0.0,"parent":"T1"},
{"id":"S1","name":"Test 3","qty":6.0,"parent":"C1"},
{"id":"S2","name":"Test 4","qty":6.0,"parent":"C1"},
{"id":"S3","name":"Test 5","qty":6.0,"parent":"C1"}
]
var StandardGrid = declare([Grid, Keyboard, Selection, Selector, Editor, dgridTree]);
var CustomStore= declare([Rest, dstoreTree]);
var myStore = new CustomStore({
target: "./data.json",
idProperty: "id",
getRootCollection: function () {
return this.root.filter({ parent: null });
},
getChildren: function (object) {
return object.parent = object.id;
},
mayHaveChildren: function (object) {
return object.parent == null;
},
});
var treeGrid = window.treeGrid = new StandardGrid({
collection: myStore.getRootCollection(),
columns: [
{ renderExpando: true, label: "Name", field: "name", sortable: false },
{ label: "Quantity", field: "qty" },
]
}, "treeGrid");
treeGrid.startup();
我还尝试参考以下链接,但仍然无法弄清楚: dgrid 0.4.0 tree 在用户交互之前看起来很平坦
提前感谢和感谢。