简体   繁体   中英

Change BackgroundColor of particular row dynamic in DataGrid in flex

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.

Take a look at this post :

Setting background color for datagrid row in Adobe Flex

Does it answer your question?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM