File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Expand and Fold GWT Tree

 
Sergey Kargopolov
Ranch Hand
Posts: 63
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

I am having difficulty with Expanding and Folding the GWT Tree.

When user selects TreeItem with a mouse click I want the Tree to expand. And when user clicks on TreeItem again I want the Tree to Fold. The problem is that if I click on TreeItem when Tree is unfolded it Folds, and then immediately unfolds again. Looks like SelectionEvent is triggered twice . Here is my code:


public void onSelection(SelectionEvent<TreeItem> event) {
TreeItem t = event.getSelectedItem();
boolean isOpen = t.getState();

if(isOpen)
{
t.setState(false);

} else {
t.setState(true);
}
});

Please advise me...

Thank you.
 
Rakesh Chaudhary
Ranch Hand
Posts: 120
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Try this

webpage

BOB..


 
Sergey Kargopolov
Ranch Hand
Posts: 63
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rakesh, thank you very much for your post.

I am sorry, may be I did not describe my problem clear enough but I cannot find an example that folds and unfolds GWT Tree by selecting or clicking on Tree Item. I cannot find SelectionEvent example. Clicking on "+" is not what I am interested in. I need Tree to unfold and fold when users clicks on TreeItem. Code that I posted above does not work as I expect it to work. An event is triggered twice.

Thank you.
 
dayananda veerappa
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any help on this, why an event is triggered twice onselection method
 
Daniel Renner
Greenhorn
Posts: 10
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look after the content of the event. Maybe the click event also triggers the select event (2 calls, select + click). I develop only in gxt, with a different event handling, but there more than 1 way to catch events. Is there something similar to addListener(Events.OnSelect, new ..listener()); in GWT?
 
dayananda veerappa
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you so much for replay, tree don't have addListener(Events.OnSelect, new ..listener()); method,
can you post sample code for gxt. thanks inadvance
 
Daniel Renner
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nah, you dont need the gxt code. It doesnt help you.
So can you please post the code where you define the listener for the tree (method)? Which gwt version do you use?
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic