From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of vnice Cute
Sent: Monday, September 05, 2005
11:30 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Custom
CellRenderer displaying multy colors
When i use the attached script i got the change for all other statment.
i want to display the cell color for each country.
i have attached the code.
hope to get help in that.
****************** DataGrid2.mxml **********************
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
verticalGap="20" backgroundColor="#7BB5BF" pageTitle="Phone
Book Report">
<mx:Model id="PhoneBook"
source="C:\Inetpub\wwwroot\PhoneBook\PhoneBook.XML"/>
<mx:Script>
public var aDP:Array = [ {fname:0, cocode:0}, {mname1:1,
cicode:1}, {mname1:2, number:2}, {Lname:3}];
private function NameCombine(oItem:Object):String
{
return oItem.fname + " " + oItem.mname1 +
" " + oItem.mname2 + " " + oItem.Lname;
}//NameCombine
private function NoCombine(oItem:Object):String
{
return oItem.cocode + "-" + oItem.cicode +
"-" + oItem.number;
}//NoCombine
</mx:Script>
<mx:DataGrid id="dg"
dataProvider="{PhoneBook.Details}" height="90%"
vGridLineColor="#999900" headerColor="#993333"
rollOverColor="#FFCC99">
<mx:columns>
<mx:Array
id="arr">
<mx:DataGridColumn labelFunction="NameCombine"
headerText="Name" width="150"/>
<mx:DataGridColumn columnName="country"
headerText="Country"
cellRenderer="SimpleCustomCellRenderer"/>
<mx:DataGridColumn columnName="city"
headerText="City" />
<mx:DataGridColumn labelFunction="NoCombine"
headerText="Phone Number" width="100"/>
<mx:DataGridColumn columnName="date"
headerText="Date" />
</mx:Array>
</mx:columns>
</mx:DataGrid>
</mx:Application>
********************************************************
**************** SimpleCustomCellRenderer.mxml *******************
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
verticalGap="20" backgroundColor="#7BB5BF"
pageTitle="Phone Book Report">
<mx:Model id="PhoneBook"
source="C:\Inetpub\wwwroot\PhoneBook\PhoneBook.XML"/>
<mx:Script>
public var aDP:Array = [ {fname:0, cocode:0}, {mname1:1,
cicode:1}, {mname1:2, number:2}, {Lname:3}];
private function NameCombine(oItem:Object):String
{
return oItem.fname + " " + oItem.mname1 +
" " + oItem.mname2 + " " + oItem.Lname;
}//NameCombine
private function NoCombine(oItem:Object):String
{
return oItem.cocode + "-" + oItem.cicode +
"-" + oItem.number;
}//NoCombine
</mx:Script>
<mx:DataGrid id="dg"
dataProvider="{PhoneBook.Details}" height="90%"
vGridLineColor="#999900" headerColor="#993333"
rollOverColor="#FFCC99">
<mx:columns>
<mx:Array
id="arr">
<mx:DataGridColumn
labelFunction="NameCombine" headerText="Name"
width="150"/>
<mx:DataGridColumn columnName="country"
headerText="Country"
cellRenderer="SimpleCustomCellRenderer"/>
<mx:DataGridColumn columnName="city"
headerText="City" />
<mx:DataGridColumn
labelFunction="NoCombine" headerText="Phone Number"
width="100"/>
<mx:DataGridColumn columnName="date"
headerText="Date" />
</mx:Array>
</mx:columns>
</mx:DataGrid>
</mx:Application>
********************************
******************* PhoneBook.XML **********************
<?xml version="1.0"?>
<PhoneBook><Details><fname>Alaa</fname><mname1>a</mname1><mname2>a</mname2><Lname>T</Lname><country>Jordan</country><city>Amman</city><cocode>962</cocode><cicode>79</cicode><number>999999</number><date>23.Aug.2005</date></Details><Details><fname>Alaa</fname><mname1>a</mname1><mname2>a</mname2><Lname>T</Lname><country>Jordan</country><city>Amman</city><cocode>962</cocode><cicode>79</cicode><number>999999</number><date>31.Aug.2005</date></Details><Details><fname>Suha</fname><mname1></mname1><mname2></mname2><Lname>S</Lname><country>Jordan</country><city>Amman</city><cocode>962</cocode><cicode>79</cico
de><number>0000000</number><date>22/08/2005</date></Details><Details><fname>Ahmed</fname><mname1></mname1><mname2>Abdel</mname2><Lname>Aziz</Lname><country>Germany</country><city>Amman</city><cocode>962</cocode><cicode>79</cicode><number>999999</number><date>31/08/2005</date></Details></PhoneBook>
*************************************************************