0

I have Ext.tree.Panel and I use Ext.data.TreeStore for my tree.

var storeTree = Ext.create('Ext.data.TreeStore', {
    expanded: false,
    proxy: {
        type: 'ajax',
        url: '/tree'
    },
    root: {
        text: 'Ext JS',
        id: 'src',
        expanded: true
    },
    folderSort: true,
    sorters: [{
        property: 'text',
        direction: 'ASC'
    }]
});

Everything works!

But I need now something like that: at the first time, when I open page, when my tree will be loaded, I need to get JSON Tree from the another location (For example , first time I want to get JSON from /tree1 and then , when I expand my tree, to get from /generalTree);

In the other words, At the first time, I want to load tree from anotther JSON. I don't know now. Or may I send parameter , to the server, which will tell it, that it is first time of using tree (Hey, server, tree is expanded automatically by me, not from user clicking)

grep
  • 5,465
  • 12
  • 60
  • 112

2 Answers2

1

Solution in Ext.tree.Panel

listeners : {

        beforeload: function ( th, records, successful, operation, eOpts ){
          console.log("load");
          storeTree.getProxy().extraParams.().extraParams.changableParam  = 'second';
          storeTree.getProxy().url = '/another url';
        }

}
grep
  • 5,465
  • 12
  • 60
  • 112
-1

You can call the load method on the store and use another url for the request or add parameters:

// different URL
storeTree.load({
    url: '/treeinit'
});

// parameters
storeTree.load({
    params: {
        init: true
    }
});
matt
  • 4,027
  • 2
  • 25
  • 32
  • No, No. After first load, I don't want to load another JSON together. it gets 2 responses. I deed only one response. – grep Oct 15 '13 at 12:55
  • I'm not sure if I get what you're trying to say here. Please be more specific of what you're actually trying to achieve. Just for clarification, I was suggesting two **alternative** approaches, of course you won't need both of them at the same time. – matt Oct 15 '13 at 13:13
  • they create two requests. Firts request is created by your code (one of them), and another is created by the treestore proxy – grep Oct 15 '13 at 13:15
  • The store should not do a request automatically, if it is configured correctly. Do not use autoLoad on the store and try setting expanded to `false` on your root node. – matt Oct 15 '13 at 13:31
  • after some configuration yes. then you need also children:[] in root:{} – grep Oct 15 '13 at 13:45