1

when I use the LazyTreeGrid, I met a little problem; I have the file JSON like this:

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

I have no idea about how to set children in ForestStoreModel, maybe like childrenAttrs:['description.compents'] (unfortunately, it doesn't work...)?

2 Answers2

0

I found one solution, we can use onComplete like this

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

That works fine for me.

0

I had the same same problem with a Json File and a normal lazyloading Tree.

To get the children, id did it like this

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

I dont know if you have to get your json file from another server, but maybe it will work similar!

Greetings,

Alex

  • Thank you Alex, the problem is that the children doesn't in the following level ( in `description.compents`). So I solved this problem with using `onComplete( item.dataDescription.components );` :) – BlaBla-BiuBiu Apr 07 '16 at 21:35