4 Replies Latest reply on Nov 21, 2008 4:58 AM by nimo22

    .rich-table-row not behaves like .tr

    nimo22

      I have this in my css:

      I want to set the style of a row in a rich-data-table:

      This does not work:

      .myDataTable .rich-table-row {
      
      background: url(../myBackground) 0 0 repeat;
      
      }


      This does work:
      .myDataTable tr {
      
       background: url(../myBackground) 0 0 repeat;
      }



      Another point is,

      why I have to use java-script

      <rich:dataTable styleClass="myDataTable "
       onRowMouseOver="this.style.backgroundColor='#FFFF11'" onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"...>



      to make a hover-effect on rows, when I can use css:

      This does work in a rich-table without java-script:

      .dataTableSection tr:hover {
      
       backgroundColor="#FFFF11";
      }



      This does not work:

      .myDataTable .rich-table-row:hover{
      
      backgroundColor="#FFFF11";
      
      }


      We do not need java-script to hover a row, but it would be senseful, if we could provide zebra-tables with tags inside a rich:dataTable.

      For example:

      <rich:dataTable styleClass="myDataTable "
       oddRow="this.style.backgroundColor='#FFFF11'" evenRow="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"...>


      oddRow and evenRow with Java-script makes sense, but a hover with java script is not really a need as we can do it with simple css.

      Would it be not better to provide oddRow and evenRow as additional properties for rich:dataTable?

        • 1. Re:  .rich-table-row not behaves like .tr
          nimo22

          I do some prototype to color all odd table rows in my rich:dataTable:

          This works, but for ALL tr's:

          "$$(tr:nth-child(odd)').invoke('addClassName', 'myClass)"


          I only want to set my rich:dataTable tr's:

          But the selection of my ID richTable does not work:

          "$('richTable').$$(tr:nth-child(odd)').invoke('addClassName', 'myClass)"


          What is wrong?

          • 2. Re:  .rich-table-row not behaves like .tr
            nbelaevski

            Hi,

            I've created an issue about wrong class used: https://jira.jboss.org/jira/browse/RF-5007

            • 3. Re:  .rich-table-row not behaves like .tr
              nbelaevski

               

              $('richTable')
              try to use
              $(#{rich:clientId('richTable')})
              instead

              • 4. Re:  .rich-table-row not behaves like .tr
                nimo22

                Okay this code works, but styles all odd rows of my site:

                <script>
                $$('tr:nth-child(odd)').invoke('addClassName', 'myStyle')
                </script>
                



                I only want to style the odd rows of my datatable and not all rows of my site, so I tried that:


                <script>
                $('#{rich:clientId('dataTableViewUsers')}').$$('tr:nth-child(odd)').invoke('addClassName', 'myStyle')
                </script>
                


                But the failure occurs:

                $("mySite:myRichTable").$$ is not a function


                (So the correct ID of my table is found..).

                I tried it also this way and no failure occurs. However, no rows get styled:

                <script>
                $$('#{rich:clientId('dataTableViewUsers')} tr:nth-child(odd)').invoke('addClassName', 'myStyle')
                </script>
                


                Well, I guess, it s prototype-specific and not really a richfaces-problem..