PDA

View Full Version : Treepanel ?



muncher
28 Jun 2010, 4:42 PM
What kind of data is expected by a Tree panel ? I am wanting to write a dynamically populated treepanel. There are examples around ...
for ex. http://examples.extjs.eu/treestate.html

but it has get-node.php code written in there .:-?

Ant1105
28 Jun 2010, 8:06 PM
Check out the docs for TreeLoader. It is expecting an array of tree node objects...

http://www.sencha.com/deploy/dev/docs/?class=Ext.tree.TreeLoader

muncher
29 Jun 2010, 8:49 AM
thnx. I forgot to mention that I had checked that. I haven't worked with services generating a json response. Not sure what it looks like.

Animal
29 Jun 2010, 9:47 AM
So what are you asking then?

CrazyEnigma
29 Jun 2010, 10:01 AM
We have no clue what your backend technology is, so we can't write the code for you. Neither would we.

Try your hand at writing a service response in the form that it shows in the API, and see what TreeLoader does?

muncher
29 Jun 2010, 11:36 AM
hmm. Ok after some hacks around and tools I figured out what a service output should look like.

For example -


@RequestMapping(value = "/items.json")
public ModelAndView show() {
Map model = new HashMap();

//"id":"57","nodeID":"57","pnodeID":"56","text":"Americas","leaf":false
model.put("id", "44");
model.put("text", "Schmitt");
model.put("leaf", "false");
return new ModelAndView("jsonView", model);
}

I am using spring/java in the back end. Now that done ... my ultimate goal is to generate a ajax request when I click on a node in a tree.


my folder structure for the time being looks like this -
I have a jsp folder that has the sample tree app in it.


I have a listener to the TreePanel looks like



listeners: {
click: function(n) {
Ext.Msg.alert('Navigation Tree Click', 'You clicked: ' + n.attributes.id);

//Ext.Msg.alert(conn);
Ext.Ajax.request({
url: 'booksearch/items.json',
method: 'GET',
success: function(responseObject) {
Ext.Msg.alert('Status', 'Ajax Working');
},
failure: function() {
Ext.Msg.alert('Status', 'Unable to show history at this time. Please try again later.');
}

});
}
}


but this ajax request isn't working :(

So question is -
1. how do I know what is the full/absolute url that the request gets mapped to ultimately. Most likely the request url is wrong.

2. booksearch is a servlet mapping. Not sure if the folder structure is the problem.

-Mag.

muncher
29 Jun 2010, 12:52 PM
i had a big reply. But waiting for admin approval. Anyways, got hold of it.
Now thing that I am looking for is adding the children dynamically to a node and then expanding it accordingly.

Any examples ?

Animal
29 Jun 2010, 1:44 PM
TreeLoader docs shows EXACTLY what is needed.

CrazyEnigma
2 Jul 2010, 9:30 AM
Are you using the TreeLoader? The click event will fire automatically for you (on the +/- and if the node is not a leaf). What is your response? Are you using FireBug to see what requests are sent, and what your response is?

FYI: you can delete posts 6 and 7 to clean up the thread a little bit.