5 Replies Latest reply on May 5, 2008 3:12 PM by supernovasoftware.com

    DataTable different row colors?

    defrian

      Hello!

      Perhaps a simple question for an richfaces expert.
      I already searched the forum for "row colors" without success.

      I need to give my dataTable a zebra look. for that i want to color the table rows alternately grey or white. how can i get this?

        • 1. Re: DataTable different row colors?
          daedlus

          did u try rowClasses attribute?

          • 2. Re: DataTable different row colors?
            ratondeau

            yes simple indeed

            you have to set the rowClasses of rich:dataTable for example if you want to use grey and white you write something like this:


            <rich:dataTable rowClasses="greyRow, whiteRow">...


            where the Classes have to be defined in a css file e.g.

            .greyRow{
            background: #eee;
            }


            Bye Matt

            • 3. Re: DataTable different row colors?

              My problem is closely related to this post.

              I have a column in my entity class.
              @Column(name = "ENABLED", nullable = false, length = 1)
              @Type(type = "yes_no")
              @NotNull
              public Boolean getEnabled() {
              return this.enabled;
              }

              In my richfaces datatable, I would like to display all rows which have enabled='N' to a grey background and enabled='Y' to a white background color. How do I do this?

              Setting it to

              <rich:dataTable id="burstList"
               var="burst"
               value="#{burstList.resultList}"
               rendered="#{not empty burstList.resultList}"
               rowClasses="#{burst.enabled} ? enabledrow, disabledrow : ''"
               >


              of course does not give me the expected result.




              • 4. Re: DataTable different row colors?
                eicki

                Try setting style class on each column tag as you did in the datatable. That should work.

                • 5. Re: DataTable different row colors?

                  I would prefer that I could set the row css by el directly.

                  I have to put it on every column. This is not optimal.