Change BackgroundColor of particular row dynamic in DataGrid in flex

1.5k views Asked by At

I am trying to change Mx DataGridColumn background color depend on it's data dynamically but didn't get/found any solution for that.

<mx:DataGrid id="orderDG" dataProvider="{ordersList}" >
        <mx:columns>                    
            <mx:DataGridColumn width="30" headerText="Number" dataField="no" />

            <mx:DataGridColumn width="250" headerText="fname" dataField="fname">

            <mx:DataGridColumn width="250" headerText="lname" dataField="lname">

         </mx:columns>
</mx:DataGrid>

Now, suppose i want to make row color green if fname=abc and color red if fname=xyz.

How i can change background and text color of only that row.

Edit:

I will try creating custom renderer like following way.

override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
            super.updateDisplayList(unscaledWidth, unscaledHeight);

            setStyle("color", MATCH_COLOR );

        }

But it will change color of only one cell not whole row.

1

There are 1 answers

3
Gurtej Singh On

Take a look at this post :

Setting background color for datagrid row in Adobe Flex

Does it answer your question?