How to conditionally style a row in a rich:dataTable


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




Horizontal placement of components in JSF

1:



What will be better view with JSF technology
I do as you've already mentioned and put the style on the column..
How to validate datatable in JSF
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..
After rich:extendedDataTable sortby, other actions are not getting executed
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.


jsf immediate=“true” regarding binding to session bean
Should work - you may not even need the column group in the header??.
HIt counter in JSF
Eg..
User activation problem in JSF by providing a link to user?
<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> 


JSF web application with ICEfaces component

2:


Specifically for each column:.
<rich:column styleClass="#{someBean.isSomething ? 'styleIfTrue' : 'styleIfFalse' }"> 


3:


This is my code, there is a checkbox on each row, if a checkbox is selected, the row is highlighted:.
<rich:dataTable value="#{manageOutstandingApprovals.approvalsResults}" var="approvals" styleClass="wp100 mtb20"  sortMode="single" id="approvalsTable"               enableContextMenu="false" selectionMode="none" reRender="actions" rows="10">          <rich:column styleClass="#{approvals.rowcolor}" width="5%" sortBy="#{approvals.documentType}" sortOrder="#{manageOutstandingApprovals.documentTypeSort}">           <f:facet name="header">             <h:outputText value="#{messages['outstandingApprovals.documentType']}"/>           </f:facet>           <h:outputText  value="#{messages[approvals.documentType]}" id="col1"/>         </rich:column>          <rich:column styleClass="#{approvals.rowcolor}" width="5%" sortBy="#{approvals.documentID}" sortOrder="#{manageOutstandingApprovals.documentIDSort}">           <f:facet name="header">             <h:outputText value="#{messages['outstandingApprovals.documentID']}"/>           </f:facet>           <h:outputText value="#{approvals.documentID}" id="col2"/>         </rich:column>          <rich:column styleClass="#{approvals.rowcolor}" width="10%" sortBy="#{approvals.dateSubmitted}" sortOrder="#{manageOutstandingApprovals.dateSubmittedSort}">           <f:facet name="header">             <h:outputText value="#{messages['outstandingApprovals.dateSubmitted']}"/>           </f:facet>           <h:outputText value="#{approvals.dateSubmitted}" id="col3"/>         </rich:column>          <rich:column styleClass="#{approvals.rowcolor}" width="15%" sortBy="#{approvals.submittedBy}" sortOrder="#{manageOutstandingApprovals.submittedBySort}">           <f:facet name="header">             <h:outputText value="#{messages['outstandingApprovals.submittedBy']}"/>           </f:facet>           <h:outputText value="#{approvals.submittedBy}"  id="col4"/>         </rich:column>          <rich:column styleClass="#{approvals.rowcolor}" width="20%" sortBy="#{approvals.orgName}" sortOrder="#{manageOutstandingApprovals.organizationSort}">           <f:facet name="header">             <h:outputText value="#{messages['outstandingApprovals.userOrg']}"/>           </f:facet>           <h:outputText value="#{approvals.orgName}"  id="col5"/>         </rich:column>          <rich:column styleClass="#{approvals.rowcolor}" width="5%" sortBy="#{approvals.value}" sortOrder="#{manageOutstandingApprovals.valueSort}">           <f:facet name="header">             <h:outputText value="#{messages['outstandingApprovals.value']}"/>           </f:facet>           <h:outputText value="#{approvals.value}"  id="col6"/>         </rich:column>          <rich:column styleClass="#{approvals.rowcolor}" width="20%" sortBy="#{approvals.approverUserName}" sortOrder="#{manageOutstandingApprovals.approverSort}">           <f:facet name="header">             <h:outputText value="#{messages['outstandingApprovals.approver']}"/>           </f:facet>           <h:outputText value="#{approvals.approverUserName}"