tags:

views:

7

answers:

0

Hello,

I'm trying to add itemRenderer on ADG's column on conditional basis. My code is as follows,

var columns:XMLList = XMLList(xcCols);
                        var cols:Array = new Array();

                        //Loop through each column and build column based on xml configuration
                        for each (var column:XML in columns)
                        {
                            var col:AdvancedDataGridColumn = new AdvancedDataGridColumn(column);         
                            col.headerText=column.@label;    
                            //col.dataField=column;
                            if(column=="hazard") {        
                                col.itemRenderer = new ClassFactory(RenderCategory);
                            }
                            col.width=Number(column.@width);                    
                            cols.push(col);
                        }
                        //Set custom columns to grid control
                        dataGrid.columns = cols;

Here is xcCols's xml chunk,

<column label="Hazard" viewByDefault="true" width="100">hazard</column>
<column label="Status" allowGrouping="true" viewByDefault="true" width="20">status</column>

Here is code for RenderCategory.as ,

package com.flexrish
{
    import mx.controls.*;
    import mx.controls.dataGridClasses.*;


import mx.controls.*;
import mx.controls.dataGridClasses.*;
import mx.collections.XMLListCollection;
public class RenderCategory extends Label
{
    // setting data and design
    override public function set data(value:Object):void
    {
        if (value!=null)
        {
            var columns:XMLList = XMLList(value);
            for each (var column:XML in columns)
            {
                if(column.category.@type=="s") {
                    setStyle("color", 0x898B8C);
                }   
            }
        }
        super.data=value;
    }

} }

But It doesn't work.. If I remove conditional check then it works but on wrong column ..I would appreciate any help on this.