1. #1
    Ext GWT Premium Member
    Join Date
    Sep 2011
    Posts
    14
    Vote Rating
    0
    B.Oury is on a distinguished road

      0  

    Question Unanswered: Treepanel : The grandparents of selected tree node is NULL

    Unanswered: Treepanel : The grandparents of selected tree node is NULL


    Hi,
    I've a problem when I click on a node with depth 2, I can't recover its grandparents, there is null.

    Code:
      TreeStore<BeanModel> objStore = new TreeStore<BeanModel>();
      TreePanel<BeanModel> objTree = new TreePanel<BeanModel>(objStore);
    
    objTree.getSelectionModel().addListener(Events.BeforeSelect, new Listener<SelectionEvent<BeanModel>>() {
    
          @Override
          public void handleEvent(SelectionEvent<BeanModel> be) {
            AgdRdvDTO selectAppointment = null;
            AgdDemandeDTO selectDemande = null;
            AgdSuiviDTO selectSuivi = null;
    
            TreePanelSelectionModel<BeanModel> tree = (TreePanelSelectionModel<BeanModel>) be.getSource();
            BeanModel item = be.getModel();
            if (item.getBean() instanceof AgdDemandeDTO) {
              selectDemande = item.getBean();
            } else if (item.getBean() instanceof AgdSuiviDTO) {
              selectSuivi = item.getBean();
              selectDemande = objStore.getParent(item).getBean();
            } else if (item.getBean() instanceof AgdRdvDTO) {
              selectAppointment = item.getBean();
    
              BeanModel beanSuivi = objStore.getParent(item);
              selectSuivi = beanSuivi.getBean();
              BeanModel grandParents= objStore.getParent(objStore.getParent(item));
              if (grandParents!= null) {
                selectDemande = grandParents.getBean();
              }
              AgendaEventBus.getEventBus().fireEvent(new SelectDetailEvent(selectDemande, selectSuivi, selectAppointment));
            }
          }
        });
    The first time I clicked, grandParents is initialized and if i clicked on an other item of the same parent, the grandParents is always null.

    Thanks for your help

  2. #2
    Sencha Premium Member
    Join Date
    Aug 2011
    Posts
    15
    Answers
    1
    Vote Rating
    0
    dariusjb is on a distinguished road

      0  

    Default


    You should try get the store reference everytime you need it. May be one update/load has changed it. Therefore your reference does not reflect what is actually in it.

    tree.getStore() instead of using objStore

  3. #3
    Sencha Premium Member
    Join Date
    Aug 2011
    Posts
    15
    Answers
    1
    Vote Rating
    0
    dariusjb is on a distinguished road

      0  

    Default


    I meant:
    objectTree.getStore()

Thread Participants: 1