【问题标题】:Rich Faces dataTable StyleClass IssueRich Faces 数据表样式类问题
【发布时间】:2014-06-01 14:29:57
【问题描述】:

版本:

Apache MyFaces 2.1.14 富面孔 4.3.5

问题:

我们正在从 JSF1.2 迁移到 JSF2。问题是 headerClass 的样式没有正确应用于rich:dataTable。 调试时,富面孔似乎用自己的样式覆盖了 headerClass 样式。 丰富面孔的样式选择器 .rf-dt-hdr-c 会覆盖自定义样式表选择器。 (我们想用自定义标题图像替换标题的颜色)

最后,当丰富的面孔提供样式(.rf-dt-hdr-c) 被覆盖时,如下面的代码所示,它起作用了。 但由于它是内置于 style 中的丰富面孔,它将应用于每个 rich:dataTable,这可能不是一个好的选择。 类似here 所示的方法在这里不起作用,因为没有将自定义样式与内置样式相结合的规定。 有没有更好的方法可以解决这个问题? 有什么方法可以与 .rf-dt-hdr-c 一起应用自定义样式,这样它就不会在全局范围内生效? 请帮忙。

代码:

丰富的数据表sn-p:

 <rich:dataTable id="admin" headerClass="richTableHeader1" styleClass="richDataTable1" rowClasses="evenRow,oddRow" 
                    columnClasses="columnRow" value="#{bean.list}" var="val">

样式:

.richDataTable1{    
    width:100%; 
}

<!-- this is the headerClass style used to apply custom image (not working )-->
.richTableHeader1{

    background-image:url(../images/heading1.gif) !important;
    background-color: #FFFFFF !important;
}

<!-- rich faces applied style overriden (working )-->
.rf-dt-hdr-c{
    background-image:url(../images/heading1.gif) !important;
    background-color: #FFFFFF !important;

}

【问题讨论】:

    标签: jsf-2 richfaces


    【解决方案1】:

    这是一个表头:

    <thead id="form:j_idt10:th" class="rf-dt-thd">
        <tr id="form:j_idt10:h" class="rf-dt-hdr">
            <th class="rf-dt-hdr-c" colspan="2" scope="colgroup">Table</th>
        </tr>
    </thead>
    

    @headerClass 应用于tr.rf-dt-hdr 元素。因此,您必须将定义更改为

    .richTableHeader1 th {
        background-image:url(../images/heading1.gif) !important;
        background-color: #FFFFFF !important;
    }
    

    您也可以使用@headerCellClass,它不是文档中的功能,但它可以工作。

    【讨论】:

    • 非常感谢 Makhiel。两种方法都工作得很好。我为此付出了很多努力。唯一的是,我无法理解使用 .richTableHeader1 th 而不是 .richTableHeader1 tr 的原因。我的意思是为什么只有这种组合。
    • 嗨 Makhiel,了解使用 .richTableHeader1 的原因。非常感谢。
    猜你喜欢
    • 2014-06-05
    • 1970-01-01
    • 2013-05-19
    • 2011-11-21
    • 2011-08-25
    • 1970-01-01
    • 2013-04-11
    • 2011-10-01
    • 1970-01-01
    相关资源
    最近更新 更多