【问题标题】:Set width for JSF column header in fixed-size table在固定大小的表格中设置 JSF 列标题的宽度
【发布时间】:2012-09-24 05:22:51
【问题描述】:

我有一个带有 table-layout:fixed 的 JSF 数据表,我正在尝试为每列设置基于百分比的宽度。我想如果我在 IE 的标题中添加一个宽度属性,那么它会按预期工作。但是,我不知道如何在代码中添加这个宽度属性。 我在构面标题中添加了一个属性,但这不起作用。在列标签内设置它也不起作用。

如果有人可以帮助我,将不胜感激。

<h:column>
     <f:facet name="header">
         <h:outputText 
             value="#{messageSource['tasks.headline.task']}" />
             <f:attribute name="width" value="20%"/>
     </f:facet>
     <t:commandLink id="lookAtTask" action="lookAtTask">
         <t:updateActionListener property="#{flowScope.localTask}"
             value="#{data.task}" />
         <h:graphicImage url="/images/icon_properties_16x16.gif"
             alt="#{messageSource['tasks.headline.task']}" />
     </t:commandLink>
</h:column>

【问题讨论】:

标签: jsf datatable facet column-width


【解决方案1】:

您可以使用&lt;h:column&gt;headerClass 属性来指定标题的样式类。

<h:dataTable ...>
    <h:column headerClass="col1">
        <f:facet name="header">...</f:facet>
        ...
    </h:column>
    <h:column headerClass="col2">
        <f:facet name="header">...</f:facet>
        ...
    </h:column>
    <h:column headerClass="col3">
        <f:facet name="header">...</f:facet>
        ...
    </h:column>
</h:dataTable>

例如这个CSS

.col1 { width: 20%; }
.col2 { width: 30%; }
.col3 { width: 50%; }

【讨论】:

  • 出于某种原因headerClass 对我不起作用。 styleClass 成功了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-13
  • 1970-01-01
  • 2018-01-16
  • 1970-01-01
  • 2014-02-10
  • 2014-11-14
相关资源
最近更新 更多