Flex: Adding a tooltip to truncated Datagrid columns
June 13th, 2008 | Posted by in Actionscript | FlexI just found a nice way to automatically truncate text in datagrid columns and show tooltips for truncated elements, that I wanted to share:
package { import mx.controls.dataGridClasses.DataGridItemRenderer; public class TruncateToolTipRenderer extends DataGridItemRenderer { private var textTruncated:Boolean = false; private var originalText:String; public function TruncateDataGridItemRenderer() { super(); } override public function set text(value:String):void { super.text = value; originalText = value; textTruncated = truncateToFit(); } override public function validateProperties():void { super.validateProperties(); toolTip = textTruncated ? originalText : null; } } }
Just set the itemRenderer property of your column to the new TruncateToolTipRenderer. Neat!
Update: … and it’s a lot easier if you just set the itemRenderer to mx.controls.Label, because a Label already has truncate and tooltip functionality. As so often in Flex, everything is built in. Lesson learned!
You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.


Really good component. I had my problem solved in matter of minutes. Thank you very much.
Pingback: Flex : Tooltip on Fixed Width DataGrid Columns | Anuj Gakhar's Blog
Pingback: Flex : Tooltip on Fixed Width DataGrid Columns | Flash Player roundup
Awesome component! Thanx a million.
i am using inline image itemrenderer in datagrid and written a method to make it visible or invisible on itemClick.
my next requirement is to create a datatip or tooltip or any method(to be called on rollover) when the image is visible the content of that tooltip is from arraycollection other than the dataprovider arraycollection.
please reply on my mail:
feerozhuma@yahoo.com