设置冻结列的宽度

时间:2014-06-06 17:20:29

标签: css jsf jsf-2 primefaces datatable

我尝试使用PrimeFaces ShowCase中的冻结列。

但是我无法设置第一个冷冻柱的宽度,这实在太宽了。

Exemple

有人可以告诉我如何解决它?

XHTML:

<p:dataTable var="car" value="#{dtScrollView.cars}" 
             scrollable="true" scrollHeight="150"
             scrollWidth="300" frozenColumns="1">
   <p:column headerText="Id" footerText="Model">
      <h:outputText value="#{car.model}" />
   </p:column>
   <p:column headerText="Year" footerText="Year">
      <h:outputText value="#{car.year}" />
   </p:column>  
</p:dataTable>

我正在使用PrimeFaces 5.0。

3 个答案:

答案 0 :(得分:8)

要更改冻结列的宽度,请使用以下CSS类:

/* Change frozen width */
.ui-datatable-frozenlayout-left {
   width: 20%;
}

这是一个online Demo,以及github上的示例代码。

希望这有帮助。

答案 1 :(得分:-1)

尝试以下代码

<p:column headerText="Id" footerText="Model" style="width:20px;">
    <h:outputText value="#{car.model}" />
</p:column>

您可以根据需要更改宽度值

答案 2 :(得分:-1)

HY,

<p:column>中添加属性样式,如下所示:

<p:column headerText="Id" footerText="Model" style="width: 10%;">
                <h:outputText value="#{car.model}" />
            </p:column>

尝试一下,没关系:)

enter image description here