Color the rows of datatable based a condition in JSF 2

后端 未结 2 1352
轮回少年
轮回少年 2020-12-19 09:40

I\'d like to change the background color of rows based on a condition.



        
相关标签:
2条回答
  • 2020-12-19 10:17

    You can use JSF EL Ternary operator, as below:

    rowStyleClass="#{entry.action eq X ? 'history-table-row-incomplete' :  (entry.action eq Y ? 'history-table-row-error' : 'default')}"
    
    0 讨论(0)
  • 2020-12-19 10:38

    Use the rowStyleClass attribute of the <t:dataTable> instead of rowClasses. The rowStyleClass is evaluated on a per-row basis where the var="entry" is available, while the rowClasses is only evaluated on a per-table basis.

    <t:dataTable ... rowStyleClass="#{entry.action == 'X' ? 'history-table-row-incomplete' : (entry.action == 'Y' ? 'history-table-row-error' : 'history-table-row-default')}">
    
    0 讨论(0)
提交回复
热议问题