Java 如何设置空素面数据表的宽度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6641639/
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 to set width of empty primefaces datatable
提问by hudi
I am using primefaces datatable. How to set width when the table is empty ? because in this case the table smaller when they have some record, I try use style
我正在使用 primefaces 数据表。表格为空时如何设置宽度?因为在这种情况下,当他们有一些记录时表格会变小,我尝试使用样式
style="width: 150%"
or
或者
style="width: 200px"
but with no success.
但没有成功。
And it is possible to change default text "No records found." to something else ?
并且可以更改默认文本“未找到记录”。去别的地方?
采纳答案by Mark
<p:dataTable style="width:25px;">
will change the width of the table, but the column headers and the message displayed when there are no records also effects the width of the table.
<p:dataTable style="width:25px;">
会改变表格的宽度,但列标题和没有记录时显示的消息也会影响表格的宽度。
Check the text in your column headers. The text will not line break between words, so the column will have a minium width based on the header text.
检查列标题中的文本。文本不会在单词之间换行,因此该列将具有基于标题文本的最小宽度。
<p:column>
<f:facet name="header">
<h:outputText value="This is a long column header" />
</f:facet>
<h:outputText value="#{bean.value}" />
</p:column>
The No Records Found
message will line break between words
该No Records Found
消息将一行字之间断
so it will only effect the width if one of the words in the message is to long.
所以只有当消息中的一个词太长时,它才会影响宽度。
<p:dataTable style="width:25px;" emptyMessage="thisisalongmessagefornodata">
回答by Jim Tough
The <p:dataTable>
has a emptyMessage
attribute. Set it to a String value and it will be displayed when the source data collection for your table is empty.
该<p:dataTable>
有一个emptyMessage
属性。将其设置为字符串值,当表的源数据集合为空时将显示该值。
回答by Daniel
For empty message:
对于空消息:
<p:dataTable emptyMessage="No records found." style="text-align: center;" ...
For "blank" line:
对于“空白”行:
<p:dataTable emptyMessage=" " style="text-align: center;" ...
And if it's important to have the columns aligned left, do:
如果让列左对齐很重要,请执行以下操作:
<p:column rendered="true" style="text-align: left;">
回答by Paulo Gama
Try this:
尝试这个:
<p:column style="white-space: nowrap">