Search code examples
jsfseamrichfaces

How to conditionally style a row in a rich:dataTable


How can I change the style of a particular row based on a condition? I can use JSF EL in rich:column style class attribute, but I have to write for each column. I want to change the entire row.

Thanks


Solution

  • I do as you've already mentioned and put the style on the column.

    However you could always try wrapping all of your columns in a <rich:columnGroup> which is supposed to output a <tr> and place your conditional style on that.

    EDIT: (in response to comment): if the header facets in your columns are being broken then you can separate them into a column group as well. Should work - you may not even need the column group in the header??

    Eg.

    <rich:dataTable>
      <f:facet name="header">
        <rich:columnGroup>
          <rich:column>Header 1</rich:column>
          <rich:column>Header 1</rich:column>
        </rich:columnGroup>
      </f:facet>
      <rich:columnGroup>
        <rich:column>Data</rich:column>
        <rich:column>Data</rich:column>
      </rich:columnGroup>
    </rich:dataTable>