1 Reply Latest reply on Jan 14, 2009 10:41 AM by linuxtuxie.j_007_b.live.com

    Highlighting rows in rich:dataTable based on the row content

    linuxtuxie.j_007_b.live.com

      Hi all,


      I am able to highlight certain rows in a rich:dataTable based on the row content by making use of the rowClasses tag by generating the value for the rowClasses tag.


      However, if I add a rich:datascroller to the dataTable and use the sorting stuff, things break :)


      The rowClasses value is not updated when I sort one of the columns....so in short, I do not get feedback from the rich:dataTable.
      Is there a way to know which row is where in the rich:dataTable ?


      or is there another and/or better method to accomplish this?

        • 1. Re: Highlighting rows in rich:dataTable based on the row content
          linuxtuxie.j_007_b.live.com

          I solved my own problem by implementing the following code:


          Instead of generating the rowClasses attribute for the rich:dataTable tag, I generate the value for the styleClass attribute on the rich:column tag for each row. Each time the dataTable gets rerendered (due to filtering or sorting) it calls the getColor method for each cell


          example:



          <rich:dataTable id="itemData" var="item" value="#{items}" reRender="ds" rendered="#{items.rowCount!=0}">
             <rich:column styleClass="#{item.color}" sortBy="#{item.name}" filterBy="#{item.name}" filterEvent="onkeyup">
                <f:facet name="header">Name</f:facet>
                <h:outputText value="#{item.name}" />
             </rich:column>
          
             <rich:column styleClass="#{item.color}" sortBy="#{item.value}" filterBy="#{item.value}" filterEvent="onkeyup">
                <f:facet name="header">Value</f:facet>
                <h:outputText value="#{item.value}" />
             </rich:column>
          
             ...
             ...
          
             <f:facet name="footer">
                <rich:datascroller id="ds" renderIfSinglePage="true"/>
             </f:facet>
          </rich:dataTable>



               





          And here item.color contains the texts greenRow;redRow;... which on its turn is defined in the stylesheet