« Korax Color Picker | Main | Uploader »
DataGrid Row Colors
| By Rich Tretola | July 27, 2006 | |
| 4,558 views |
Tim Hoff has posted a new datagrid component that can be used to conditionally change rowColors through CSS. Here is the link: http://www.iepl.net/DataGridRowColorSample/DataGridRowColorSample.html

UPDATE: AS BOB STATED, THE LINK NO LONGER GOES TO THE FLEX SOURCE CODE, I WAS ABLE TO PULL THE ORIGINAL SOURCE FROM GOOGLE CACHE AND HAVE PROVIDED IT BELOW.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:local="*" layout="vertical" verticalAlign="middle" horizontalAlign="center" verticalGap="8" creationComplete="initData();" viewSourceURL="srcview/index.html"> <mx:Style source="Styles.css"/> <mx:Script> <![CDATA[ import mx.collections.ArrayCollection; private var dgArray:Array = [ {account:'Test Account #01', startDate:'02/15/2005', status:'Active', accountBalance:21.55}, {account:'Test Account #02', startDate:'03/05/2006', status:'Delinquent', accountBalance:-52.29}, {account:'Test Account #03', startDate:'01/21/2004', status:'Closed', accountBalance:0}, {account:'Test Account #04', startDate:'12/31/2001', status:'Active', accountBalance:19.95}, {account:'Test Account #05', startDate:'03/05/2006', status:'Delinquent', accountBalance:-502.34}, {account:'Test Account #06', startDate:'01/21/2004', status:'Closed', accountBalance:0}, {account:'Test Account #07', startDate:'12/31/2001', status:'Active', accountBalance:19.95}, {account:'Test Account #08', startDate:'03/05/2006', status:'Deleted', accountBalance:0}, {account:'Test Account #09', startDate:'01/21/2004', status:'Closed', accountBalance:0}, {account:'Test Account #10', startDate:'12/31/2001', status:'Active', accountBalance:319.88}, {account:'Test Account #11', startDate:'09/01/2002', status:'Delinquent', accountBalance:-87.22}]; [Bindable] private var dgArrayCollection:ArrayCollection; private function initData():void { dgArrayCollection=new ArrayCollection(dgArray); } private function startDateLabel(item:Object, column:DataGridColumn):String { return df.format(item.startDate); } private function accountBalanceLabel(item:Object, column:DataGridColumn):String { return cf.format(item.accountBalance); } ]]> </mx:Script> <mx:CurrencyFormatter id="cf" precision="2"/> <mx:DateFormatter id="df" formatString="MM/DD/YYYY"/> <mx:Label text="DataGrid rowColors Component Sample" width="100%" color="white" fontSize="14" fontWeight="bold" textAlign="center"/> <local:RowColorDataGrid id="dg" dataProvider="{dgArrayCollection}" width="500" height="310" borderThickness="2" styleName="rowColorsDataGrid"> <local:columns> <mx:Array> <mx:DataGridColumn width="160" paddingLeft="6" headerText="Account" dataField="account"/> <mx:DataGridColumn width="120" textAlign="center" headerText="Start Date" dataField="startDate" labelFunction="startDateLabel"/> <mx:DataGridColumn width="160" paddingLeft="6" headerText="Status" dataField="status"/> <mx:DataGridColumn width="80" textAlign="right" headerText="Balance" dataField="accountBalance" labelFunction="accountBalanceLabel"/> </mx:Array> </local:columns> </local:RowColorDataGrid> <mx:Label text="(Right Click to View Source)" width="100%" color="white" fontSize="11" fontWeight="bold" textAlign="center"/> </mx:Application> |
Topics: Components, Flex 2 | 5 Comments »








July 5th, 2008 at 8:35 pm
Sadly this is now a broken link as it goes no where near anything looking like Flex related coding.
Reply to this comment
July 6th, 2008 at 7:58 am
Thanks Bob, please see my update above.
Reply to this comment
October 2nd, 2008 at 11:23 pm
I cannot find Styles.css. Please attack this file!
Reply to this comment
Rich Tretola Reply:
October 3rd, 2008 at 4:15 am
I apologize but since the original site is no longer available, the source is gone for the css file.
Reply to this comment
October 5th, 2009 at 9:57 pm
I found this site with a working (and rather nice) solution for the problem. It works with callbacks instead of CSS and is really portable and efficient.
The link is http://www.switchonthecode.com/tutorials/flex-datagrid-goodies-row-color-and-others
I hope this helps!
Kind regards – Thomas
Reply to this comment