View Full Version : loading a form from a tree event
fernando
15 Oct 2007, 11:37 AM
Hi guy's,
I have a tree which lists a load of things from my server. I want to be able to click a leaf and have it load data into a form. I'm using xml to load the tree and I would like to use xml to load the form as well. Each tree node has a unique id which can be used to pull specific data from the server. Using the href attribute I'm sure I can get the server to produce the xml. Do I need to add a listener for a load event?
Is there a better way to do this? Sorry I'm still fairly new to programming so any hints would be much appreciated.
cheers
evant
15 Oct 2007, 2:06 PM
Something like:
myTree.on('click', function(node)
{
//get data from server.
}
);
fernando
15 Oct 2007, 11:55 PM
Cheers Evant(again!),
However I've now got a new problem. As I mentioned before I am using xml to load the tree, my code is based on Animals(http://extjs.com/forum/showthread.php?t=3987). I process the xml differently but basically make nodes, and attach them to each other, and return 'result'.
From a seperate javascript file (containing Ext.onReady), doing:
var xmlTree = new createXmlTree('tree-div', 'treeData/')
xmlTree.on('click', function(node){
alert('node clicked');
});
Gives an error in FireBug:
'xmlTree.on is not a function'
I also tried:
alert(Ext.type(xmlTree));
and got:
'Object'
Do I need to cast xmlTree to Ext.Tree?
Any help much appreciated
evant
16 Oct 2007, 12:42 AM
Why are you passing new? From a quick glance, isn't it just a function that creates a tree?
var xmlTree = createXmlTree('tree-div', 'treeData/')
xmlTree.on('click', function(node){
alert('node clicked');
});
fernando
16 Oct 2007, 7:38 AM
Yes your right it is just a function that creates a tree. So I removed the new and changed the code to:
var xmlTree = createXmlTree('tree-div', 'treeData/')
xmlTree.on('click', function(node){
alert('node clicked');
});
now I get a:
'xmlTree has no properties'
in FireBug.
Sorry if this is basic but I'm not sure whats going wrong. Setting a breakpoint to look at xmlTree gives it's value as 'undefined'.
I've a feeling that this is something basic but I havn't a clue whats going wrong.
so if anyone could give me any tips they would be much appreciated.
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.