【问题标题】:Add multiple colours in PrimeFaces dataTable row在 PrimeFaces 数据表行中添加多种颜色
【发布时间】:2015-04-24 13:12:40
【问题描述】:

基于下拉值,我想以多色显示数据表行。我遵循this 示例,但它显示所有行绿色或红色

我的代码:-

<p:dataTable id="empAtendanceTable"
             var="report"
             value="#{empBean.empReport}"
             rowStyleClass="#{report.status==false ? 'colored' : null} #{report.status==true ? 'error' : null}">

CSS:

.colored {
    background: red;
    color: white;
}
.error {
    background: green;
    color: white;
}

如何改变颜色?我使用的是 PrimeFaces 5.1 版本。

【问题讨论】:

    标签: css jsf primefaces


    【解决方案1】:

    试试:

     <p:dataTable id="empAtendanceTable"
                 var="report"
                 value="#{empBean.empReport}"
                 rowStyleClass="#{report.status ? 'error' : 'colored'}">
    

    【讨论】:

    • ,感谢您的回复,根据情况,它工作正常。非常感谢。
    【解决方案2】:

    您需要更改“背景颜色”属性。例如:

    .colored {
       background-color: red;
       color. white;
    }
    

    这可能对你有帮助。

    【讨论】:

    • 与问题无关。 background 速记属性在一个声明中设置所有背景属性。
    • 根据条件,行会有所不同。如果状态为“P”表示红色,“A”表示绿色。
    猜你喜欢
    • 2017-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-14
    • 1970-01-01
    相关资源
    最近更新 更多