Hmm, you must have something going on that
interferes. This little example works for me:
App.mxml
<?xml version="1.0"
encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.macromedia.com/2003/mxml"
xmlns="*">
<mx:DataGrid
dataProvider="{[{foo: 'bar'}, {foo: 'bar'}, {foo: 'baz'}]}">
<mx:columns>
<mx:Array>
<mx:DataGridColumn
columnName="foo" cellRenderer="bgCell"/>
</mx:Array>
</mx:columns>
</mx:DataGrid>
</mx:Application>
bgCell.mxml
<mx:VBox
xmlns:mx="http://www.macromedia.com/2003/mxml">
<mx:Script>
<![CDATA[
var value : String;
function setValue(v) : Void
{
value = v;
setStyle("backgroundColor",
v == 'baz' ? 0xff0000 : undefined);
}
]]>
</mx:Script>
<mx:Label text="{value}"
/>
</mx:VBox>
Matt
From: Andrew Spaulding
[mailto:[EMAIL PROTECTED]
Sent: Wednesday, February 02, 2005
8:11 PM
To: [EMAIL PROTECTED]
Subject: [flexcoders] Re: simple
datagrid cell colour renderer
Also, now that I overwrite these methods when i
scroll up and down the
grid the rows gradually increase in height ...
there must be a better
way to size the VBox?
--- In [email protected], Matt Chotin
<[EMAIL PROTECTED]> wrote:
> Did you try setting width/height to 100%?
>
>
>
> _____
>
> From: Andrew Spaulding [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, February 02, 2005 8:01PM
> To: [email protected]
> Subject: [flexcoders] Re: simple datagrid
cell colour renderer
>
>
>
>
> Thanks Matt,
>
> I had already taken that option, now I have
to get the VBox to resize
> to the available space in the cell. I would
assume this would mean
> overwriting the getPrefferedHeight and
getPreferredWidth methods.
>
> Thanks,
>
> Andrew.
>
>
>
>
>
> --- In [email protected], Matt
Chotin <[EMAIL PROTECTED]> wrote:
> > You could just use a VBox with a label
inside of it. In the
> setValue method
> > you'd simply set the backgroundColor
style on the VBox (in addition
> to the
> > text of the label).
> >
> >
> >
> > Matt
> >
> >
> >
> > _____
> >
> > From: Andrew Spaulding
[mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, February 02, 20054:58
PM
> > To: [email protected]
> > Subject: [flexcoders] simple datagrid
cell colour renderer
> >
> >
> >
> >
> > Hi all,
> >
> > Im trying to write a cell rendererthat
changes the background colour
> > of a cell depending on the number that
is displayed in it.
> >
> > Is this a simple task? I'm really
struggling ... Should I make the
> > cell renderer a text box and just set
the background colour on that?
> >
> > Best,
> >
> > Andrew.
> >
> >
> >
> >
> >
> >
> > _____
> >
> > Yahoo! Groups Links
> >
> > * Tovisit
your group on the web, go to:
> > http://groups.yahoo.com/group/flexcoders/
> <http://groups.yahoo.com/group/flexcoders/>
> > <http://groups.yahoo.com/group/flexcoders/
> <http://groups.yahoo.com/group/flexcoders/>
>
> >
> > * To
unsubscribe from this group, send an email to:
> > [EMAIL PROTECTED]
> >
<mailto:[EMAIL PROTECTED]>
> >
> > * Your use
of Yahoo! Groups is subject to the Yahoo!
> > <http://docs.yahoo.com/info/terms/
<http://docs.yahoo.com/info/terms/>
>
> Terms of Service.
>
>
>
>
>
>
> _____
>
> Yahoo! Groups Links
>
> * To visit your
group on the web, go to:
> http://groups.yahoo.com/group/flexcoders/
> <http://groups.yahoo.com/group/flexcoders/>
>
> * To
unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]
>
<mailto:[EMAIL PROTECTED]>
>
> * Your use of
Yahoo! Groups is subject to the Yahoo!
> <http://docs.yahoo.com/info/terms/>
Terms of Service.