OK, try adding this to the cell renderer:

 

        var owner;

        function getPreferredHeight() : Number

        {

            return owner.layoutHeight;

        }

 

Matt

 


From: Andrew Spaulding [mailto:[EMAIL PROTECTED]
Sent: Wednesday, February 02, 2005 9:06 PM
To: [EMAIL PROTECTED]
Subject: [flexcoders] Re: simple datagrid cell colour renderer

 


Here's some sample code to demonstrate what I'm talking about. You can
see that the problem in the last row of the grid.


App.mxml
<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
xmlns="*">

    <mx:DataGrid variableRowHeight="true"
          dataProvider="{[{foo: 'bar', doo: 'This is some sample text'},
{foo: 'bar'}, {foo: 'baz', doo: 'This is some sample text, this is
some sample text'}]}">

        <mx:columns>

            <mx:Array>

                <mx:DataGridColumn columnName="foo"
cellRenderer="bgCell" />
                <mx:DataGridColumn columnName="doo" wordWrap="true" />

            </mx:Array>

        </mx:columns>

    </mx:DataGrid>

</mx:Application>


bgCell.mxml
<?xml version="1.0" encoding="utf-8"?>

<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>


Andrew.


Reply via email to