How do I conditionally color the background in a table cell?

前端 未结 2 1404
难免孤独
难免孤独 2020-12-29 15:43

I am rendering a table with p:dataTable (PrimeFaces) and what I want to do is color the background of cells depending on the value of their content. This i

2条回答
  •  没有蜡笔的小新
    2020-12-29 16:17

    You can add a css class to the row and to the column too, that identifies a cell. Use the dataTable's rowStyleClass attribute (example). If you want to color multiple rows:

    
         ...
         
    

    css:

    .firstColColored .firstCol {
         background: pink;
    }
    

提交回复
热议问题