java 如何控制 Vaadin 表的列宽?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3414190/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I control column width of the Vaadin Table?
提问by dhaval
I have a large table to display in one of our Vaadin application. The table has 110 columns with large text header for each column.
我有一张大表要显示在我们的 Vaadin 应用程序之一中。该表有 110 列,每列都有大文本标题。
On display the table looks awful as all the column header goes off the screen and the header separator loses the alignment with the data record column separator.
在显示时,表格看起来很糟糕,因为所有列标题都离开了屏幕,并且标题分隔符与数据记录列分隔符失去了对齐。
I have set the table width to 100% to display the table scrollbar. I tried to set columnExpandRatio as well as column width but no success.
我已将表格宽度设置为 100% 以显示表格滚动条。我试图设置 columnExpandRatio 以及列宽,但没有成功。
Vaadin table by default sets the text header width as the column width. Is there any way i can set the header/column width to fit my data rather the header?
Vaadin 表默认将文本标题宽度设置为列宽。有什么方法可以设置标题/列宽度以适合我的数据而不是标题?
采纳答案by dhaval
Finally as a solution I assigned no width value to initial columns (like first 30 columns will span naturally) and later columns with fixed width size with setColumnWidth() and it worked.
最后,作为一个解决方案,我没有为初始列分配宽度值(比如前 30 列将自然跨越)和后来的列使用 setColumnWidth() 固定宽度大小,并且它起作用了。
回答by Mogudoom
Please use table column name hide which s very useful for the viewer can choose what are the column he is able to view ...
请使用表列名隐藏这对查看者非常有用可以选择他能够查看的列...

