[flexcoders] List ItemRenderer and variableRowHeight

2008-02-26 Thread Phil Heinz
I have a List component with a custom item renderer. The List is set
to variableRowHeight=true.

In the renderer is a regular TextArea component that I want to grow in
size vertically for the longer data strings.

My problem is I don't quite understand how to automate the process of
sizing the TextArea and then the renderer height from the
TextArea.textHeight property.

I can successfully do it manually, attaching a click event to the
TextArea, that calls the following function in the renderer:

private function updateHeight(ev:MouseEvent):void {
 ev.target.height = ev.target.textHeight + 5;
 this.height = ev.target.y + ev.target.height + 25;
}

This perfectly sizes each item when I click on them. 

The problem is I can't get it to function properly when I try to size
them from an event representing the item's creation. I have tried
sizing on the following events:

1) renderer creationComplete and added events
2) in the data setter override function for the renderer

No matter what I try to do, automated sizing produces incorrect
results. I am sure I just don't understand - not the first time!!!

Thanks for any help!!!
Phil



RE: [flexcoders] List ItemRenderer and variableRowHeight

2008-02-26 Thread Alex Harui
Unless you want the TextArea's scrollbars, you should just set
wordWrap=true and the default renderer will take care of it.  If you
want to customize the renderer, copy the code and modify it.  TextArea
is a bit heavy for renderers especially if you don't need the
scrollbars, and the default renderer code will show you how to figure
out the appropriate measuredHeight.

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Phil Heinz
Sent: Tuesday, February 26, 2008 10:05 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] List ItemRenderer and variableRowHeight

 

I have a List component with a custom item renderer. The List is set
to variableRowHeight=true.

In the renderer is a regular TextArea component that I want to grow in
size vertically for the longer data strings.

My problem is I don't quite understand how to automate the process of
sizing the TextArea and then the renderer height from the
TextArea.textHeight property.

I can successfully do it manually, attaching a click event to the
TextArea, that calls the following function in the renderer:

private function updateHeight(ev:MouseEvent):void {
ev.target.height = ev.target.textHeight + 5;
this.height = ev.target.y + ev.target.height + 25;
}

This perfectly sizes each item when I click on them. 

The problem is I can't get it to function properly when I try to size
them from an event representing the item's creation. I have tried
sizing on the following events:

1) renderer creationComplete and added events
2) in the data setter override function for the renderer

No matter what I try to do, automated sizing produces incorrect
results. I am sure I just don't understand - not the first time!!!

Thanks for any help!!!
Phil