2 Replies Latest reply on Jan 14, 2009 4:39 AM by linuxtuxie

    Highlighting rows in rich:dataTable based on the row content

    linuxtuxie

      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 con
          ilya_shaikovsky

          as for me it works completely wrong even without scroller under 3.3.0.
          https://jira.jboss.org/jira/browse/RF-5636

          b.t.w. for h:dataTable - it works fine before and also after table pages ajax scrolling

          • 2. Re: Highlighting rows in rich:dataTable based on the row con
            linuxtuxie

            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