View Full Version : Setting a dataURL for a TreePanel's loader dynamically

16 Sep 2009, 10:34 PM

I have created a window object which uses a TreePanel.
I would like to set the dataURL of the treePanel's loader object dynamically.

Below is my code, with a static dataURL:

copyWindow = Ext.extend(Ext.Window, {
title: 'copy',
layout: 'fit',
buttonAlign: 'center',
initComponent: function() {

var Tree = Ext.tree;
var root = new Tree.AsyncTreeNode({
text: 'Departments',
draggable: false,
expanded: true,
rootVisible: false,
id: 'source'

this.treePanel = new Tree.TreePanel({
autoScroll: true,
animate: true,
lines: true,
containerScroll: true,
loader: new Tree.TreeLoader({
dataUrl: 'WS.asmx/GetGroups'


root: root,
rootVisible: false



When creating a window object (var win = new copyWindow()),

How can I set the dataURL?


16 Sep 2009, 10:55 PM
copyWindow.treePanel.getLoader().dataUrl = 'newurl';

(and I assume you want to reload the root node after that?)

17 Sep 2009, 1:01 AM
Thanks for your reply.

Eventualy, I used the following:

var dataUrl = 'myURL';
var title = 'myTitle'

var win = new copyWindow({ dataUrl: dataUrl, title: title});

I have a new problem though - when selecting nodes in the window's tree and pressing a 'copy' button, I am trying to fetch all of the selected nodes.
The problem is that I always get the first selected node ONLY.

Here is the relevant code:

var copyButton = new Ext.Button({
text: 'copy',
scope: this,
minWidth: 75,
handler: this.onCopy

onCopy: function() {
var nodes = this.treePanel.getSelectionModel().getSelectedNodes();


'nodes' contain only 1 node, even though I selected more.

Please let me know if I should open a new thread for that.

Thank you