I want to create Ext.tree.TreePanel component and periodically load content from the external URl. So I've written something like
new Ext.tree.TreePanel({
root: {
nodeType: 'async',
text: 'asdasd',
draggable: false,
id: 'folders-tree-root'
},
loader: new Ext.tree.TreeLoader()
});
And now I want to reload this tree, so I write:
tree.loader.dataUrl = 'folders-sample.json';
tree.root.reload();
And nothing happens.
add:
The only way I've found is set some invalid value to dataUrl
param on TreeLoader
creation:
new Ext.tree.TreePanel({
root: {
nodeType: 'async',
text: 'asdasd',
draggable: false,
id: 'folders-tree-root'
},
loader: new Ext.tree.TreeLoader(dataUrl: 'something')
});
What you're looking for is the load
method for the TreeLoader. So something like this should work given your example.
tree.getLoader().load(tree.root);
Here's my full example that's available on my demo site as well. It's a little contrived and hacked together from one of the ExtJS demo's but it should get you what you need.
Ext.onReady(function() {
var root = new Ext.tree.AsyncTreeNode({
text: 'Ext JS',
id: 'src'
});
var reloadTree = function() {
tree.enable();
tree.getLoader().dataUrl = 'get-nodes2.php';
tree.getLoader().load(tree.root);
};
var tree = new Ext.tree.TreePanel({
animate: true,
autoScroll: true,
nodeType: 'async',
loader: new Ext.tree.TreeLoader(),
containerScroll: true,
border: false,
disabled: true,
id: 'myTree'
});
var myPanel = new Ext.Panel({
items: tree,
border: false,
tbar: [{
text: 'Refresh',
handler: reloadTree
}]
});
tree.setRootNode(root);
myPanel.render('tree');
});
Cheers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With