NewCodeLearner
NewCodeLearner

Reputation: 738

Expand and reduce the TreeItem , on the selection of Other TreeItem in GWT

I am using GWT , I have tree Widget.TreeItems are added at runtime. example:

   1.A
   2.B

when i click on A It looks like

    1.A
       1.ab
       2.cd
    2.B

When I click on B It looks like

    1.A
       1.ab
       2.ad
    2.B.
       1.bz
       2.by

I want is like, when i click on B , all the TreeItem should be reduced. like:

     1.A
     2.B.
       1.bz
       2.by

i am confused how to do this.

i am using on SelectionHandler to expand the treeItem.

Can somebody help me to understand and how to do this. Also the keywords to do this.

Edited : More Information

This A and B are the TreeItems of the same tree and are addded at run time.

public void onSelection(SelectionEvent<TreeItem> event) {
// the item which is selected send some keyword to server and server returns the child of the treeItem 
}

.

Upvotes: 1

Views: 609

Answers (1)

Alain BUFERNE
Alain BUFERNE

Reputation: 2061

You can on the selection handler of B use closeAll() (Tree class method) which will closes all the nodes of the Tree and after use openAll(TreeNode node)(Tree class method) to open B and all the nodes under B. To access directly to the Tree under your TreeGrid use the method yourTreeGrid.getTree() so it will be for example `yourTreeGrdi.getTree().closall().

Regards Alain

Upvotes: 1

Related Questions