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({
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