1

Wenn ich die LazyTreeGrid verwende, traf ich ein kleines Problem; Ich habe die Datei JSON wie folgt aus:Wie können wir Kinder in Dojo TreeGrid setzen?

{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'} 
    ]  
} 
} 

Ich habe keine Ahnung, wie Kinder in ForestStoreModel, vielleicht wie childrenAttrs:['description.compents'] einzustellen (leider funktioniert es nicht ...)?

Antwort

0

fand ich eine Lösung, wir onComplete wie diese

var model = new ForestStoreModel({ 
    getChildren : function (item, onComplete, onError) { 
     onComplete(item.dataDescription.components); 
     } 
}); 

Das ist für mich gut funktioniert verwenden können.

0

Ich hatte das gleiche Problem mit einer Json-Datei und einem normalen Lazyloading-Tree.

Um die Kinder zu bekommen, id es wie diese

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}); 
      } 
     }); 
tat

ich weiß nicht, ob Sie Ihre JSON-Datei von einem anderen Server erhalten müssen, aber vielleicht wird es ähnlich funktionieren!

Grüße,

Alex

+0

Danke Alex, das Problem ist, dass die Kinder in der folgenden Ebene nicht (in 'description.compents'). Also habe ich dieses Problem mit 'onComplete (item.dataDescription.components) gelöst;' :) –

+0

Ahh, okay, ich verstehe es. Problem gelöst, perfekt! :-) –