问题
I have a custom renderer (inherits from AdvancedDataGridItemRenderer
), and I'm overriding validateProperties
and using the value of the width
property, but I'm getting the old value every time! Isn't validateProperties
supposed to execute after the properties were committed (I'm calling super)? Here's my code:
public override function validateProperties():void
{
super.validateProperties();
if ((AdvancedDataGrid(listData.owner).columns[listData.columnIndex].
showDataTips)&&(textWidth>width))
toolTip=listData.label;
else toolTip=null;
}
Thanks!
回答1:
you should do this in the data setter for your item renderer:
public override function set data(val:Object):void{
super.data=val;
if ((AdvancedDataGrid(listData.owner).columns[listData.columnIndex].
showDataTips)&&(textWidth>width))
toolTip=listData.label;
else toolTip=null;
}
回答2:
It is better to override width setter or to handle "textFieldWidthChange" event.
回答3:
I solved it. The trick is to use validateSize
for the width
property. validateProperties
is for properties that don't belong to any of the other groups for which there's a dedicated validateX
function (such as validateSize
, validateList
, etc.).
来源:https://stackoverflow.com/questions/13680993/the-property-still-has-the-old-value-in-validateproperties