Vaadin 中的过滤器树
我想根据某些编辑框中的文本(在文本更改时)隐藏 vaadin 树的叶子。 即,如果编辑框中的文本是“ab”,我只想显示文本以“ab”开头的叶子。 如果文本为空,我想显示所有叶子。
我怎样才能做到这一点?
I want to hide leafs from vaadin tree according to text in some editbox (on text change).
ie if text in editbox is "ab" i want to show only leafs with text starting with "ab".
and if text is empty, i want to show all leafs.
How can i make that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须过滤附加到树的数据容器。
版本 6.6.0 中引入了新的过滤器 API,它允许您创建自定义过滤器。我还没有尝试过新的 API,但在你的情况下,它应该像这样工作:
其中 textField 是你的“编辑框”,dataContainer 是数据容器,附加到您的树,properyId 是包含要过滤的文本的容器字段的属性 ID。
请注意,上述代码未经测试,因为我目前无法访问适当的开发工具。
You will have to filter the data container which is attached to the tree.
A new Filter API was introduced in version 6.6.0 which allows you to create custom Filters. I haven't tried the new API yet, but in your case it should work like this:
in which textField is your "editbox", dataContainer is the data container which is attached to your tree and properyId is the property id of the container field which contains the text you want to filter.
Note that the above code is untested because I currently can't access the appropriate development tools.