Vaadin - 多选项卡布局
我有几个 Vaadin 选项卡,其中一个显示表格和一些按钮,另一个显示分层 Vaadin 树并具有自定义搜索框。我已将选项卡的大小设置为 H:420px W:250px,因此它们具有相同的大小,如果表格太大或树太长,我会得到一个滚动条(这就是我想要的),问题是其他组件就像搜索框和按钮被强制向下放置在布局的底部一样,所以如果我想访问按钮/搜索框,我必须一直向下滚动,这样我才能使用我想要的组件。我尝试仅为组件添加第二个布局,但没有帮助:-/这是我迄今为止尝试过的:
TabSheet tabs = new TabSheet();
tabs.setWidth("250");
tabs.setHeight("420");
VerticalLayout lyTab = new VerticalLayout();
tabOne = tabs.addTab(lyTab, "Tab One", null);
//added an extra layout for the Buttons :
HorizontalLayout lyButton = new HorizontalLayout();
lyButton.addComponent(applyButton);
lyButton.addComponent(selectAll);
lyTab.addComponent(lyButton);
我的想法是向 tabSheet 添加第二个布局,这样我就可以修复它的位置,使其无法移动但这没有用。有什么想法吗?
I have few Vaadin tabs one of them is displaying an table and some buttons, another one displays an Hierarchical Vaadin tree and has an custom search Box. I have set the size of my tabs to H:420px W:250px so they have the same size, if the table gets too big or the tree to long I get an scrollbar (that’s what I wanted) the problem is that the other components like the search Box and the buttons are being forced down at the bottom of the layout so if I want to access the buttons/ search Box I have to scroll all the way down so I can use the component I want. I have tried to add an second layout only for the components but it didn’t help:-/ here’s what I have tried so far:
TabSheet tabs = new TabSheet();
tabs.setWidth("250");
tabs.setHeight("420");
VerticalLayout lyTab = new VerticalLayout();
tabOne = tabs.addTab(lyTab, "Tab One", null);
//added an extra layout for the Buttons :
HorizontalLayout lyButton = new HorizontalLayout();
lyButton.addComponent(applyButton);
lyButton.addComponent(selectAll);
lyTab.addComponent(lyButton);
my idea was to add an second layout to the tabSheet so i can fix its position so it cant move but it didnt work . any ideas ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我正确理解您的问题,这里是如何使用表格来做到这一点:
在这种情况下,表格是全尺寸的,并在需要时显示滚动条。
对于树,将上面代码中的表格部分替换为:
这里树无法显示滚动条,因此我们将其包装在一个全尺寸的面板中,该面板在需要时显示滚动条。
If I understand your problem correctly here is how to do it with a Table:
In this case, the Table is full sized and shows scrollbars when needed.
For a Tree, replace the Table part from above code with:
Here the Tree is not able to show scrollbars so we wrap it inside a full sized Panel that shows scrollbars when needed.
我在 Vaadin 7.4.8 中仍然遇到类似的问题,并且能够使其工作。
1 - 我确定的第一件事是父组件(在我的例子中,我有两个 VerticalLayout 被添加到另一个组件中)具有 setSizeFull()。它们被添加到视图中。就我而言,我忘记将其设置在扩展 VerticalLayout 和 Implements View 的类上,由导航器调用。
2 - 另一个重要的细节是 tabSheet - 使用 addTab(component) 添加的选项卡还必须设置 setSizeFull() ,以便选项卡占用所有未使用的空间,特别是在底部。
2.1 - 添加了 setExpandRatio(tabSheet, 1) 以便它向顶部移动。
3 - 现在,对于使用 addTab(component) 添加到 tabSheet 的组件(VerticalLayout),我添加了两个组件,一个是 HorizontalLayout,第二个是 VerticalLayout。
所以我确保:
I was still experiencing similar issues in Vaadin 7.4.8 and was able to make it work.
1 - The first thing I made sure was that parent components(in my case I had two VerticalLayout's being added one into another) had setSizeFull(). They are being added to a View. In my case, I forgot to set it on a Class that extends VerticalLayout and Implements View, called by navigator.
2 - The other important detail is that the tabSheet - on which tabs were added with addTab(component) must also have a setSizeFull() being set, so that the tab takes all unused space, especially on towards the bottom.
2.1 - Added a setExpandRatio(tabSheet, 1) so that it is being shifted towards the top.
3 - Now, for a component(VerticalLayout) that is being added to a tabSheet using addTab(component), I had two components added to it, one is a HorizontalLayout and the second one is a VerticalLayout.
So I made sure that :