How to set a selection in the GWT CellBrowser

663 views Asked by At

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

1

There are 1 answers

2
Ümit On BEST ANSWER

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.