PDA

View Full Version : What is correct way to build a Tree in Designer 2?



billtricarico
25 Feb 2012, 11:57 AM
Hello,

I can't seem to wire up a tree panel in Designer 2. Here is what I am doing:

1. Drag a TreePanel to the canvas. Looks like it has a built-in dummy tree structure.
2. Drag a TreeStore over to the Stores. Give it name, url, etc. It is my understanding that a TreeStore does not require an explicit model, nor explicit fields. But Designer still insists on either a model or fields added to the TreeStore. I copied the simple tree JSON from the TreePanel Sencha docs:


{
expanded:true,
children:[
{
id:1,
text:"detention",
leaf:true
},
{
id:2,
text:"homework",
expanded:true,
children:[
{
id:3,
text:"book report",
leaf:true
},
{
id:4,
text:"algebra",
leaf:true
}
]
},
{
id:5,
text:"buy lottery tickets",
leaf:true
}
]
}


and then tried to load the data. All I get is an error popup that shows "0:" in the box.

Can someone give me a step by step on how to create a simple Tree that loads data from a server?

Thanks.




Incidentally, I have a feature request: In Project Inspector, can you add the ability to right-click on those colored circles (Application, Controllers, Views, Stores, Models) and allow the just add an object? Instead of dragging the object from the left of the screen across the canvas to the right side and drop it just right?

billtricarico
26 Feb 2012, 7:26 AM
Anybody?

I really need to figure this one out.

billtricarico
26 Feb 2012, 6:23 PM
It seems to be working now.

I started over, and added a TreePanel. Then I added a TreeStore. Linked the TreePanel to the TreeStore using the storeId field. I pointed the TreeStore > MyAjaxProxy url to my hardcoded JSON on the server. I also set the TreeStore > MyAjaxProxy > MyJsonReader idProperty to id. Then I added two fields, id and text to the TreeStore.

As I said before, I am not sure why the TreeStore needs to have fields added. I figured that would be the case only if I chose to use fields with names other than id and text.

Thanks.

aconran
27 Feb 2012, 9:48 AM
Glad you figured this out.

We'll look into lifting the restrictions on TreeStore's re: fields.