Menu

Changing Row BgColor based upon Condition

Help
Dheeraj
2004-04-02
2012-10-09
  • Dheeraj

    Dheeraj - 2004-04-02

    How can i change the Background color of the row in the table, based upon some condition. When i am using a CSS class at the table level, which has the default bgColor for all the rows.

    Thanks,
    Dheeraj.

     
    • Dheeraj

      Dheeraj - 2004-04-23

      I am done with this.

      Dheeraj.

       
      • Rick Herrick

        Rick Herrick - 2005-01-06

        How did you end up solving this? Please share the solution. Thanks!

         
        • khanman

          khanman - 2007-08-02

          i came up with a manual workaround for this problem:

          For each row i generated a script as (depending on the condition):

              <script>
                  classArray[classArray.length] = "grid"; //classArray is a defined some place as var classArray = new Array();
          
              </script>
          

          Thus storing the style class for each row.

          Then on body onload() you can call the following method, that simply applies the class from the array to each row, (or to individual columns on table)

          function setColumnClass(){
          var tb = document.getElementById('recordsTable');

          var cols;
          if(tb && tb.rows && tb.rows.length){
          for(i = 1 ; i < tb.rows.length
          ; i++){
          tb.rows[i].className = classArray[i - 1];
          }
          }

          You may add futher checks to optimize the code above. Hope this helps.

           
    • saila

      saila - 2004-04-24

      Could you please share the solution?

      Thanks!
      Saila

       
      • ryanwu

        ryanwu - 2004-11-10

        I need your help too..
        chenhuan0212@pchome.com.tw

        thanks a lot

         
      • Pradeep

        Pradeep - 2005-02-04

        Could you sed your code. I have the following problem I want to change color on the column's value.

        Thanks
        Pradeep

         
    • Dheeraj

      Dheeraj - 2004-04-30

      Let me know your email id, i can send you the code, since for this i had to make some changes to display-tag code too.

      Plus i had to use ColumnDecorator.

      Dheeraj.

       
    • ritesh kumar

      ritesh kumar - 2004-10-06

      can u share ur code with me i have also same problem and one thing more i m using datasource for the showing the record how can i use wrapper class for reporting

      rgds

      ritesh

       
    • Rishi

      Rishi - 2005-01-04

      Hi Dheeraj,

      Could you share ur solution with me. I want to change the row color on row selection with mouse.

      ritesh.sood@deltion.co.uk

      Thanks,
      Ritesh

       
      • optip

        optip - 2005-01-04

        I am also interested by your code because I have the following problem I want to change color on the column's value.
        I should resolve this problem this week I hope you
        coul help me quickly.

        Thanks a lot in advance

         
    • Richard Tuquet Laburre

      I am also interested ; so if you can send your code to me, i would be happy

      richard.tuquet-laburre@itldev.fr

       
    • Richard Tuquet Laburre

      Hello
      i just found a solution to change bgcolor based upon Condition (for me when a column have a specific value)

      But my solution is not very well made as you can see if this description :

      I made a javascript "script" which makes a loop for all items of my "list object" which the display tag table ;
      in each step of this loop, i generate what i want to find if the color of the line is to change ;
      then for all lines, i try to find this value (i put this text value in a div which can be hidden)
      If i find it, that's means that the bgcolor of a line is to change; So a javascript function return the html table row which contains this value
      and with this row element, i execute row.style.background-color='red';

       
    • khanman

      khanman - 2005-02-23

      I am facing the same problem with display tag. Can you please share your solution ? My email address is faisal.moin@gmail.com

      Faisal Moin Khan

       
      • bugmenot

        bugmenot - 2005-02-23

        I submitted a patch for this feature about a week ago. You can grab the patch and read the comments at: http://jira.codehaus.org/browse/DISPL-192

         
    • Pradeep

      Pradeep - 2005-02-27

      Could you please share the solution? My email address is ipradeepkumar@yahoo.com

      Thanks
      Pradeep

       
    • haritha gavva

      haritha gavva - 2008-05-27

      I am facing the same problem with display tag. Can you please share your solution ? My email address is haritha_gavva@yahoo.com

       

Log in to post a comment.

MongoDB Logo MongoDB