Not a direct answer to your question, I know, but...

 

If your display has only one column, use a List instead of a DataGrid.

 

When I needed to do a variable height renderer, I started with the
ListItemRenderer.as code and modified it as needed.  That renderer
handles row heights very well.  The code is very clean, well commented
and easy to follow, so take a look.

 

Also, using containers (VBox) in an item renderer is less than ideal,
because they are "heavy", and you can have some performance problems if
you have a lot of them displayed.  ListItemRenderer is seriously
optimized.

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Richard Baker
Sent: Tuesday, September 16, 2008 11:16 AM
To: [email protected]
Subject: [flexcoders] VBox as itemRenderer & recycling issue?

 

Hi

I have a DataGrid with 1 column - which is a custom itemRenderer.
That's built from an MXML component file containing a VBox and 3 text
boxes stacked vertically (obviously!). Each line should be displayed
without scrollbars - variableRowHeight is set to true on the datagrid.

Problem is, each line's height seems to be set to a seemingly random
value. Sometimes it works, sometimes not. I think its to do with
itemRenderer recycling, so I am trying to explicitly set the VBox
height with a dataChange event handler:

private function onDataChange():void
{
txtQuestion.validateNow();
txtOption.validateNow();
txtFeedback.validateNow();
this.height= txtQuestion.textHeight+txtOption.textHeight+
txtFeedback.textHeight;
trace ("ondatachange :" + txtQuestion.text + this.height); 
}

the heights of the text fields (txtQuestion etc) don't seem to be
right so I am calling the validateNow to try to get the correct value,
but it's not happening for me?

Where am I going wrong?

Thanks for any help

 

Reply via email to