0

somehow I have the feeling that I miss the forest for the trees. I have a CellBrowser filled with categorys and I have a search dialog to find the categorys by name. If I now select a category in the search dialog I also want it to be selected in the CellBrowser.

What I can already do is, find the node in the category tree. I also have the path from the root node to the leaf. I can open the nodes until the selected leaf (getCellBrowser().getRootTreeNode().setChildOpen(i, true). But how do I select the leaf itself? And frankly speaking, is that the right way to do it? (I doubt it somehow)

Greetings Ole

Ole
  • 3
  • 1

1 Answers1

1

Selecting an Object in the CellWidgets can be done by via the SelectionModel.
Assuming that you have defined a SelectionModel (i.e. SingleSelectionModel) for your CellBrowser/TreeViewModel you can just select a node in a CellBrowser by calling:

selectionModel.setSelected(MyObject, true);

MyObject is the object/type which is displayed as a node in your CellBrowser.
Note you can have different types/objects for each CellBrowser level.
SelectionModel will use either a KeyProvider or the equals function to select the object.

Ümit
  • 17,379
  • 7
  • 55
  • 74
  • Hi timeu, perfekt it worked. Ok not perfekt, because I still have to navigate quite inconvenient through the tree and open the childeren by hand. But still in worked, thanks a lot. – Ole Nov 02 '11 at 14:51
  • @Ole: Glad, I could help. Yes I had the same issue with a CellTree. I had to create a recursive function to open the parent nodes until my selected object is visible. It would have been nice if the GWT team had included a method to automatically do it for you. – Ümit Nov 02 '11 at 15:20