I have an AdvancedDataGrid
with a custom renderer on one of the columns (that extends AdvancedDataGridItemRenderer
). I'm interested in displaying the full text in the column as a tooltip when it's too short for its content. With a standard renderer I can easily achieve this effect by using showDataTips
, but it doesn't work on custom renderers. I tried measuring the text width and comparing it to the column width in several ways, but I'm getting incorrect values and so far nothing worked. Here's an example:
public override function set data(value:Object):void
{
super.data=value;
var metrics:TextLineMetrics=getLineMetrics(0);
if (metrics.width>this.width) toolTip=text; else toolTip="";
}
If anybody knows the solution to this issue, I'll be glad if s/he can share.
I have actually already solved it. Here's the solution if anyone else is stuck on the same issue:
public override function validateSize(recursive:Boolean=false):void
{
super.validateSize(recursive);
if ((AdvancedDataGrid(listData.owner).columns[listData.columnIndex].
showDataTips)&&(textWidth>width))
toolTip=listData.label;
else toolTip=null;
}