1. #1
    Sencha User
    Join Date
    Jan 2010
    Posts
    91
    Vote Rating
    0
    sofway is on a distinguished road

      0  

    Default 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

  2. #2
    Sencha User
    Join Date
    Mar 2011
    Posts
    2
    Vote Rating
    0
    Flo_ is on a distinguished road

      0  

    Default


    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_

  3. #3
    Sencha User
    Join Date
    Mar 2011
    Posts
    2
    Vote Rating
    0
    Flo_ is on a distinguished road

      0  

    Default


    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 :

    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));
            }
          }
        }
    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.

    I hope that help you. if you want more details, tell me.

    A+,
    Flo_

Similar Threads

  1. Need to reload single treepanel node, and treepanel node checkbox error
    By sgdevteam in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 10 Mar 2010, 5:46 PM
  2. TreePanel text change on model not forwarded
    By LukasP in forum Ext GWT: Discussion
    Replies: 5
    Last Post: 10 Mar 2010, 10:24 AM
  3. [CLOSED] TreePanel not notify on model's changed.
    By mtarantini in forum Ext GWT: Bugs (2.x)
    Replies: 5
    Last Post: 19 Feb 2010, 2:59 AM
  4. How Do You Update Expanded Tree Node For Model Change?
    By ccocco in forum Ext GWT: Help & Discussion (1.x)
    Replies: 3
    Last Post: 6 Jun 2008, 11:14 AM

Thread Participants: 1