0
votes

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)

2

2 Answers

-1
votes

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

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

}