如何在 GWT CellBrowser 中设置选择
不知何故,我有种只见树木不见森林的感觉。我有一个充满类别的 CellBrowser,并且有一个搜索对话框可以按名称查找类别。如果我现在在搜索对话框中选择一个类别,我也希望在 CellBrowser 中选择它。
我已经可以做的是,找到类别树中的节点。我还有从根节点到叶子的路径。我可以打开节点,直到选定的叶子 (getCellBrowser().getRootTreeNode().setChildOpen(i, true)。但是如何选择叶子本身? 坦率地说,这是正确的做法吗? (不知怎的,我对此表示怀疑)
问候Ole
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 CellWidgets 中选择一个对象可以通过 SelectionModel 来完成。
假设您已经为 CellBrowser/TreeViewModel 定义了 SelectionModel(即 SingleSelectionModel),您只需通过调用以下方法即可在 CellBrowser 中选择一个节点:
MyObject 是在 CellBrowser 中显示为节点的对象/类型。
请注意,每个 CellBrowser 级别可以有不同的类型/对象。
SelectionModel 将使用 KeyProvider 或 equals 函数来选择对象。
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:
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.