The property still has the old value in validateProperties

一世执手 提交于 2019-12-13 02:43:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!