我一直在使用Primefaces很难,所以SO是我找到问题答案的最佳位置.
我有p:dataTable很多列,所以每个列都应该有很短的宽度.对于标题,它们似乎没问题,但对于数据列,它们会分为2行或更多行,这是我不喜欢的.
我将第一列的宽度设置得更大,以显示数据表中的内容.标题文本很好,保持单行.但数据列对我不利.我更喜欢他们保持单线.我不希望换行.椭圆是优选的,但不是强制性的.
<p:dataTable id="searchResultTable" var="searchData" value="#{registerBean.searchDataList}"
scrollHeight="200"
rowIndexVar="rowIndex"
rowKey="#{searchData.model}"
selectionMode="single"
selection="#{registerBean.selectedSearchData}"
paginator="true" rows="10"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,20" resizableColumns="true">
<p:ajax event="rowSelect" listener="#{registerBean.onSelectedSearchData}"/>
<p:column headerText="#{registerBean.getSearchResultHeaderText(0)}"
width="30" style="height: 10px; font-size: 8pt;">
<h:outputText value="#{registerBean.getSearchResultText(rowIndex,0)}" />
</p:column>
<p:column headerText="#{registerBean.getSearchResultHeaderText(1)}"
width="30" style="10px; height: 10px; font-size: 8pt;">
<h:outputText value="#{registerBean.getSearchResultText(rowIndex,1)}" />
</p:column>
<p:column headerText="#{registerBean.getSearchResultHeaderText(2)}"
width="30" style="10px; height: 10px; font-size: 8pt;">
<h:outputText value="#{registerBean.getSearchResultText(rowIndex,2)}" />
</p:column>
Run Code Online (Sandbox Code Playgroud)
我用于h:outputText每一列.我不坚持h:outputText,我可以使用Primefaces的任何组件都可以.
提前致谢.
我找到了解决方案.添加下面显示的CSS <p:column/>为我工作.省略号不工作但没有换行,没有扩大的线高.
<style type="text/css">
.singleLine
{
text-wrap:none;
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
}
</style>
Run Code Online (Sandbox Code Playgroud)
这样做:
<p:column headerText="Something"
width="100" styleClass="singleLine" style="height: 10px; font-size: 8pt;">
<h:outputText value="#{something.value}" />
</p:column>
Run Code Online (Sandbox Code Playgroud)
我希望它能帮助这个地球上的少数人.
| 归档时间: |
|
| 查看次数: |
15684 次 |
| 最近记录: |