2 Replies Latest reply on Jul 30, 2010 3:07 AM by Karthik@Chennai

    Regarding Grid coloring

    Karthik@Chennai

      HI ALL,

      How to show color on particluar grid row item based on first column value.Please give me a solution.

      regards,

      karthik

        • 1. Re: Regarding Grid coloring
          Matt Le Fevre Level 4

          easiest way would probably be using an itemrenderer

           

          eg:

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
              
              <mx:XML id="testData" xmlns="">
                  <root>
                      <item value="3452"/>
                      <item value="1234"/>
                      <item value="3512"/>
                      <item value="5555"/>
                      <item value="6234"/>
                      <item value="3212"/>
                      <item value="415"/>
                      <item value="9212"/>
                      <item value="1212"/>
                      <item value="30"/>
                      <item value="2841"/>
                  </root>
              </mx:XML>
              <mx:DataGrid x="23" y="39" dataProvider="{testData.item}" width="267" height="305">
                  <mx:columns>
                      <mx:DataGridColumn headerText="Column 1">
                          <mx:itemRenderer>
                              <mx:Component>
                                  <mx:Canvas backgroundColor="{determineColour(data.@value)}">
                                      <mx:Label text="{data.@value}"/>
                                  <mx:Script>
                                      <![CDATA[
                                          private function determineColour(value:int):uint{
                                              var tempCol:uint;
                                              if(value > 5000)
                                                  tempCol = 0x33FF33;
                                              else
                                                  if(value > 3000)
                                                      tempCol = 0xFFFF00;
                                                  else
                                                      if(value > 1000)
                                                          tempCol = 0xFF9900;
                                                      else
                                                          tempCol = 0xFF0000;
                                                      
                                              return tempCol;
                                          }
                                      ]]>
                                  </mx:Script>        
                                  </mx:Canvas>
                              </mx:Component>
                          </mx:itemRenderer>
                      </mx:DataGridColumn>
                  </mx:columns>
              </mx:DataGrid>
          </mx:Application>
          
          
          • 2. Re: Regarding Grid coloring
            Karthik@Chennai Level 1

            Hi Matt

            Thanks for the solution..

            regards,

            karthik