hi,
I have a datagrid with variable height. I have written a Itemrendrer for rendrering data. now there is one more part that is the text field. i would like to resize the comtainer height to that of the text field so that the text doesn't get truncated.
Thanks sohil
Following are my classes
Auto Resize Text Area
package
{
import flash.text.TextFieldAutoSize;
import mx.core.mx_internal;
import mx.controls.TextArea;
public class AutoResizeTextArea extends TextArea
{
public function AutoResizeTextArea()
{
super();
}
override public function set text(value:String):void
{
super.text = value ;
invalidateSize();
}
override public function set htmlText(value:String):void
{
super.data = value ;
invalidateProperties();
invalidateSize();
invalidateDisplayList();
}
override protected function commitProperties():void{
super.commitProperties();
}
override protected function measure():void{
super.measure();
if(mx_internal::getTextField() != null){
//validateNow();
mx_internal::getTextField().autoSize = TextFieldAutoSize.LEFT ;
mx_internal::getTextField().validateNow();
measuredHeight = mx_internal::getTextField().height;
measuredMinHeight = measuredHeight;
}
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
super.updateDisplayList(unscaledWidth,unscaledHeight);
}
}
}
ItemRendrer
<mx:Box xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:local="*" width="100%">
<mx:Label text="test" id="lbl" />
<local:AutoResizeTextArea text="{_data}" id="txt" editable="false" />
<mx:Script>
<![CDATA[
import mx.controls.List;
import mx.core.UIComponent;
import mx.controls.DataGrid;
[Bindable]
private var _data:String;
public function onresize():void{
}
public override function set data(value:Object):void{
super.data = value;
if(value != null){
_data = String(value.Name);
invalidateSize();
}
}
override protected function measure():void{
super.measure();
measuredHeight = lbl.measuredHeight + txt.measuredHeight +10;
measuredMinHeight = measuredHeight;
}
]]>
</mx:Script>
</mx:Box>
and i call this using simple list
List dataProvider="{list}" variableRowHeight="true" width="200" height="100%" itemRenderer="ItemRendrer"