hmm, that's tasty. thanks Adam. This alternates row colours in a grid, I need to alternate cell colours in a single row. A little mod of the below yields this function which I can call in the Grid initialise event.
function initRowHeaders() { for(var i:Number = 0; i < headerRow.numChildren; i++) { headerRow.getChildAt(i).setStyle('backgroundColor', i % 2 == 0 ? 'red' : 'blue'); } } DK On 8/10/05, Adam Cath <[EMAIL PROTECTED]> wrote: > Douglas, > > You can set the style in an event handler, like so: > > <mx:Grid> > <mx:Repeater id="r"> > <mx:GridRow id="row" > initialize="row[r.currentIndex] > .setStyle('backgroundColor', > r.currentIndex % 2 == 0 > ? 0xFFFFFF > : 0xDDDDDD)"> > <mx:GridItem> > ... > </mx:GridItem> > </mx:GridRow> > </mx:Repeater> > </mx:Grid> > > Enjoy, > Adam > > -----Original Message----- > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > Behalf Of Douglas Knudsen > Sent: Wednesday, August 10, 2005 2:02 PM > To: flexcoders@yahoogroups.com > Subject: [flexcoders] alternate cell colours in a grid > > got this code below building a grid dynamically....how to alternate > teh gridItem colours??? > I tried > backgroundColor='{ currentIndex%2 == 0 ? "#EEEEEE" : "#CCCCCCC" }' > but apparently can't use bindings in style settings > > oh..can't use bindings in the styleName property either. > > DK > <mx:Grid id="daGrid" horizontalGap="0" verticalGap="0"> > <mx:GridRow id="headerRow" > > <mx:Repeater id="r" dataProvider="{ getGridHeader() }"> > <mx:GridItem height="20" colSpan="4" hScrollPolicy="off" width="{ > gridWidth / numHours }" borderColor="Black" borderSides="left, right, > bottom" borderStyle="solid" borderThickness="1" ><mx:Label text="{ > r.currentItem }"/></mx:GridItem> > </mx:Repeater> > </mx:GridRow> > > > oh, > > function getGridHeader() : Array { > builds a array of values: 7AM, 8AM, 9AM, ....., > 9PM > } > return myArray; > } > > -- > Douglas Knudsen > http://www.cubicleman.com > this is my signature, like it? > > > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Search Archives: > http://www.mail-archive.com/flexcoders%40yahoogroups.com > Yahoo! Groups Links > > > > > > > > > > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com > Yahoo! Groups Links > > > > > > > -- Douglas Knudsen http://www.cubicleman.com this is my signature, like it? ------------------------ Yahoo! Groups Sponsor --------------------~--> <font face=arial size=-1><a href="http://us.ard.yahoo.com/SIG=12hr389jk/M=362131.6882499.7825260.1510227/D=groups/S=1705007207:TM/Y=YAHOO/EXP=1123781161/A=2889191/R=0/SIG=10r90krvo/*http://www.thebeehive.org ">Get Bzzzy! (real tools to help you find a job) Welcome to the Sweet Life - brought to you by One Economy</a>.</font> --------------------------------------------------------------------~-> -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/