GWT CellTree 父节点选择
我正在尝试使用 GWT CellTree 来显示异构的分层数据模型。我需要能够进行单个选择,但能够选择父节点以及子节点。例如,如果您查看 GWT 自己的 示例,你会发现它们只为离开节点提供了一种选择模型。
我尝试通过为所有节点提供一种选择模型来扩展他们的示例。然而,这似乎是不可能的。所以我最终得到了 3 个 SelectionModels,每个节点类型(Composer、PlayList、Song)一个。
我缺少什么?
提前致谢。
I'm trying to use the GWT CellTree to display a heterogeneous, hierarchical data model. I need to be able to a single selection, but be able to select Parent nodes as well as child nodes. For example, if you look at GWT's own example, you'll see that they only provide one selection model for the leave nodes.
I tried to extend their example by providing one selection model for all nodes. However, that seems impossible. So what I ended up with where 3 SelectionModels one for each node type (Composer, PlayList, Song).
What am I missing?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 TreeViewModel 的 getNodeInfo 函数中,您必须将选择模型传递给每个级别的每个新 DefaultNodeInfo 实例。
然后在 SelectionChangeEventHandler 中执行如下操作:
更新:
为了解决打字问题,您可以定义一个由所有 DTO 扩展的抽象基类。
在 DTO 中,您扩展 BaseModel 并实现抽象 getId() 方法:
In the getNodeInfo function of your TreeViewModel you have to pass the selectionModel to each new DefaultNodeInfo instance at each level.
and then in the SelectionChangeEventHandler you have do something like this:
Update:
In order to get around the typing problem, you can define an abstract base class which is extended by all your DTO's.
In your DTO's you extend the BaseModel and implement the abstract getId() method: