Hi Matt,

I have tried using a getPreferredHeight method that returns the owners
layoutHeight and this works fine, the colour fills the entire cell
now. But I still have some weird behaviour when there is a scoll bar
on my datagrid. If click and drag on the scroll bar and move it up and
down the list the rows in the datagrid gradually increase in height.

Do you have any idea what may be causing this?

Andrew.

-----------

Use the following as a demo for this behaviour:

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'}, {foo: 'bar', doo: 'This is some sample text'},
{foo: 'bar'}, {foo: 'baz', doo: 'This is some sample text, this is
some sample text'},{foo: 'bar', doo: 'This is some sample text'},
{foo: 'bar'}, {foo: 'baz', doo: 'This is some sample text, this is
some sample text'},{foo: 'bar', doo: 'This is some sample text'},
{foo: 'bar'}, {foo: 'baz', doo: 'This is some sample text, this is
some sample text'},{foo: 'bar', doo: 'This is some sample text'},
{foo: 'bar'}, {foo: 'baz', doo: 'This is some sample text, this is
some sample text'},{foo: 'bar', doo: 'This is some sample text'},
{foo: 'bar'}, {foo: 'baz', doo: 'This is some sample text, this is
some sample text'},{foo: 'bar', doo: 'This is some sample text'},
{foo: 'bar'}, {foo: 'baz', doo: 'This is some sample text, this is
some sample text'},{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;
var owner;

function setValue(v) : Void
{
value = v;

setStyle("backgroundColor", v == 'baz' ? 0xff0000 :
undefined);
}


function getPreferredHeight() : Number
{
return owner.layoutHeight;
}

]]>
</mx:Script>

<mx:Label text="{value}" />

</mx:VBox>

--- In flexcoders@yahoogroups.com, Matt Chotin <[EMAIL PROTECTED]> wrote:
> 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: flexcoders@yahoogroups.com
> 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
> <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
> <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