Vaadin 将子项添加到树表
我尝试向树表添加一个子元素(元素是一个 Bean),但不知何故结果很奇怪。我举了一个小例子。
BeanItemContainer<Project> bic = new BeanItemContainer<Project>(Project.class);
TreeTable projectTable = new TreeTable();
projectTable.setContainerDataSource(bic);
bic.addBean(Root);
bic.addBean(p1);
bic.addBean(p2);
bic.addBean(p3);
projectTable.setParent(p1, Root);
projectTable.setParent(p2, Root);
projectTable.setParent(p3, p1);
正如您在最后一行中看到的,p1 应该是 p3 的父级,结果:参见图片。(p3 成为 p2 的子级)
可以从这里访问代码:goo.gl/BMXiv
有 2 个主要文件:
TttestApplication.class
Project.class
Cs
I tried to add a child element to treetable (element is a Bean) but the somehow the result is weird. I put a small example together.
BeanItemContainer<Project> bic = new BeanItemContainer<Project>(Project.class);
TreeTable projectTable = new TreeTable();
projectTable.setContainerDataSource(bic);
bic.addBean(Root);
bic.addBean(p1);
bic.addBean(p2);
bic.addBean(p3);
projectTable.setParent(p1, Root);
projectTable.setParent(p2, Root);
projectTable.setParent(p3, p1);
As you can see in the last line p1 should be parent of p3, and the result :see the pic. (p3 become the children of p2)
Code can be accessed from here : goo.gl/BMXiv
There are 2 main files:
TttestApplication.class
Project.class
Cs
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,我无法解决上面的问题,所以我通过“addProjectToTree”加载bean
使用 addItem 时一切都会发生。
就是这样。
CS
Unfortunatelly, I could not get over the issue above, so I load beans by 'addProjectToTree'
and everything happens as usually using addItem.
That's it.
Cs