4 Replies Latest reply on Mar 24, 2011 2:53 AM by SteveRoger

    styling(filling) ADG cell depending on value

    SteveRoger Level 1

      by calling styleFunction, styling ADG data values.

      I tried this..

       

      private function adgStyleFunction(data:Object, col:AdvancedDataGridColumn):Object
      {
           return {fontWeight:'bold',textAlign:'center', color:'#FF0000'};
      }

       

      this works perfectly.

      But how to fill cell background by any color?

      selectin of color is depend on cell value.

      ex. cell values are numeric.

      cell value is less than 50, colored by red

      and more than 50, colored by green

       

      is this possible with styleFunction?

        • 1. Re: styling(filling) ADG cell depending on value
          SteveRoger Level 1

          also is this possible with Hierarchical dataprovider ADG?

          • 2. Re: styling(filling) ADG cell depending on value
            SteveRoger Level 1

            is it not possible to styling ADG cell-by-cell reading cell values in styleFunction?

             

            I had noticed one thing ...

             

            private function adgStyleFunction(data:Object, col:AdvancedDataGridColumn):Object
            {
                 return {fontWeight:'bold',textAlign:'center', color:'#FF0000', backgroundColor:'#00FF00'};
            }

             

            backgroundColor:'#00FF00' is not working.

            • 3. Re: styling(filling) ADG cell depending on value
              huangxinghui Level 1

              AdvancedDataGridItemRenderer is extend UITextField

               

              can not set backgroundColor

               

              you can customize the itemRenderer or override the ADG drawRowBackgrounds function

               

              hope help for you.

               

              Thanks.

              • 4. Re: styling(filling) ADG cell depending on value
                SteveRoger Level 1

                i do override the drawRowBackground() function

                code is as below..

                 

                package com
                {
                    import flash.display.Sprite;
                    import mx.controls.AdvancedDataGrid;
                   public class CustomADG extends AdvancedDataGrid
                    {
                        public function CustomADG()
                        {
                            super();
                        }
                        protected override function drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void
                        {
                               color=0xFF0000;
                              super.drawRowBackground(s,rowIndex,y,height,color,dataIndex);                
                        }       
                    }
                }

                 

                ADG cells are filled by #FF0000,

                But main challenge for me is that how to access ADG dataprovider hierarchicalData in this overrided function so cell value depend filling background perfectly performed.