-
17 Mar 2011 9:29 PM #1
TreePanel different Model for eatch node
TreePanel different Model for eatch node
Hi,
i need to build a tree but each node has a different estructure, filled with different models.
The examples shows that all the treepanel are filled with the same model.
any advice?
thanks!
Santiago
-
24 Mar 2011 4:30 AM #2
Hi,
I have the same problem. I want build a TreePanel with 3 levels node. But each node is a different entity type which have a BeanModelMarker interface associated. For example :
Level Node 1 : Department (parent)
Level Node 2 : System
Level Node 3 : Project (leaf)
Each Department has a list of System as field and each System has a list of Project as field. Department, System and Project entity have a BeanModelMarker interface. When i build my TreeStore from a list of Department (the parent node) then the TreePanel search inside each Department a list of Department as level node 2 (same type between each level node) and don't take account the list of System in each Department.
Build a TreePanel where each level node has their own entity type it is possible in GXT 2.2 ?
Many Thanks !
Flo_
-
25 Mar 2011 12:47 AM #3
Hi Santiago,
I found how to build a treepanel with different model for each level node. You must be used the object loadConfig in your load method of your RpcProxy. If the loadConfig object == null you must provide the list of parent node entity, else if the loadConfig instanceof your parent node entity you must provide the list of the child node entity (which can be an other entity type) ...etc So when the loadConfig instanceof your Entity, you must provide the list of the child entity within the callback.onSuccess() parameter.
I post below the example of the load method of my RpcProxy :
Here i use BeanModel with a BeanModelMarker interface for each entity and so i must convert the BeanModel into Entity with a BeanModelFactory retrieve with this command : BeanModelLookup.get().getFactory(<Entity>.class). You can use ModelData instead of BeanModel, it works fine too.Code:@Override protected void load(final Object loadConfig, final AsyncCallback<List<BeanModel>> callback) { if (loadConfig == null) { projectMapService.loadDepartments(2, new AsyncCallback<List<Department>>() { @Override public void onFailure(final Throwable arg0) { callback.onFailure(arg0); } @Override public void onSuccess(final List<Department> result) { callback.onSuccess(departmentBeanFactory.createModel(result)); } }); } else { final BeanModel model = (BeanModel)loadConfig; if (model.getBean() instanceof Department) { final List<System> result = ((Department)model.getBean()).getSystems(); callback.onSuccess(systemBeanFactory.createModel(result)); } else if (model.getBean() instanceof System) { final List<Project> result = ((System)model.getBean()).getProjects(); callback.onSuccess(projectBeanFactory.createModel(result)); } } }
I hope that help you. if you want more details, tell me.
A+,
Flo_
Similar Threads
-
Need to reload single treepanel node, and treepanel node checkbox error
By sgdevteam in forum Ext 2.x: Help & DiscussionReplies: 2Last Post: 10 Mar 2010, 5:46 PM -
TreePanel text change on model not forwarded
By LukasP in forum Ext GWT: DiscussionReplies: 5Last Post: 10 Mar 2010, 10:24 AM -
[CLOSED] TreePanel not notify on model's changed.
By mtarantini in forum Ext GWT: Bugs (2.x)Replies: 5Last Post: 19 Feb 2010, 2:59 AM -
How Do You Update Expanded Tree Node For Model Change?
By ccocco in forum Ext GWT: Help & Discussion (1.x)Replies: 3Last Post: 6 Jun 2008, 11:14 AM


Reply With Quote