简体   繁体   English

rich:dbatable中的列宽

[英]column width in rich:datatable

How to set the colum width for a rich:column inside a rich:datatable ? 如何在rich:datatable设置rich:column的colum宽度? The width attribute is being ignored. width属性被忽略。 See the following code: 请参阅以下代码:

<rich:column label="#{msg[result]}" width="150px">
<f:facet name="header">
    <h:outputText value="#{veryLongText}"/>
</f:facet>
<h:outputText value="#{someValue}" /> 
<f:facet name="footer">
    <h:outputText value="#{someValue}" /> 
</f:facet>
</rich:column>

If you render this column and veryLongText is wider than 150px it does not break it in multiple lines. 如果渲染此列并且veryLongText宽于150px,则不会在多行中将其分解。 Instead, it just ignores the column width and takes as much as space needed. 相反,它只是忽略列宽并占用所需的空间。

How to fix this? 如何解决这个问题?

Try the <rich:column> 's headerClass attribute, as so: 尝试<rich:column>headerClass属性,如下所示:

<rich:column headerClass="myWidth">
...
</rich:column>

Then, in your CSS (embedded or linked): 然后,在您的CSS(嵌入或链接)中:

.myWidth {width:150px}

You may also have some contravening "white-space" CSS property coming into play somewhere, so you might want to specify the .myWidth selector as so: 您可能还会在某处发挥一些违反“空白”CSS属性的功能,因此您可能需要将.myWidth选择器指定为:

.myWidth {width:150px; white-space:normal!important}

If you want to achieve columns with word-wrap use this one.... 如果你想用自动换行实现这个列,请使用这个....

<div style="overflow: hidden;width: 300px;word-wrap: break-word; ">
  <h:outputText value="#{someValue}" />
</div>

It is tested on both Mozilla and IE 8.0. 它在Mozilla和IE 8.0上都经过测试。

use: 使用:

style="width:150px"

or styleClass="myColumnClass" where you add in your CSS 或者在您的CSS中添加的styleClass="myColumnClass"

.myColumnClass{
 width: 150px;
}

you can use this: 你可以用这个:

<rich:column width="60px">
    <f:facet name="header">
        <h:outputText value="#{veryLongText}" />
    </f:facet>
    <div style="overflow:hidden;width:60px">
         <h:outputText value="#{someValue}" />
    </div>
</rich:column>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM