Używam Dojo ObjectStoreModel
dla widżetu dijit / Tree. Muszę skonfigurować ObjectStoreModel
użyć właściwości o nazwie parent_id
zamiast domyślnego parent
w celu dopasowania mojej struktury danych.
Masz pomysł, jak ustawić tę konfigurację?
var data = [
{
id: "world",
name: "The earth",
type: "planet",
population: "6 billion"
},
{
id: "EG",
name: "Egypt",
type: "country",
parent_id: "AF" // does not work if property is called parent_id, only parent by default
},
{
id: "Nairobi",
name: "Nairobi",
type: "city",
parent_id: "KE"
},
{
id: "Mombasa",
name: "Mombasa",
type: "city",
parent_id: "KE"
},
{
id: "SD",
name: "Sudan",
type: "country",
parent_id: "AF"
},
];
var myStore = new Memory({
data: data,
getChildren: function (object) {
return this.query({ parent: object.id });
}
});
// Create the model
var myModel = new ObjectStoreModel({
store: myStore,
query: { id: "0" }
});
// Create the Tree.
var tree = new Tree({
model: myModel
});
tree.placeAt(this.domNode);
tree.startup();
Odpowiedzi:
0 dla odpowiedzi № 1Znalazłem rozwiązanie mojego problemu
http://dojotoolkit.org/reference-guide/1.10/dijit/tree/ObjectStoreModel.html
Stwierdzając: The dojo.store must implement it’s own getChildren() method.
Dzięki temu skrypt edycji działa dobrze.
var myStore = new Memory({
data: data,
getChildren: function (object) {
return this.query({ parent_id: object.id });
}
});