开发者

flex override public function set data

I have a datagrid with itemRenderer in datagridcolumn as my custom component(c1). I am getting the dataprovider data in custom component by overriding the set data function, it is fine. But now my custom component(c1) is also having another custom component(c2).

Now the doubt is - how to get the dataprovider 开发者_JS百科data in c2 component?

Thanks in advance.


Assuming c1 is the item renderer, and c2 is a child of the itemRenderer, all you need to do is something like, binding the child component's data property to the parents data property, or just passing in just the necessary data. You may not be able to do this in the set data function as the child component may not exsist yet, so you may have to add a check to make sure the child component exsists & also set the data when the child is created.

<mx:Canvas>
   <mx:Script>
     <![CDATA[
         override public function set data(value:Object):void{
               super.data = value;
               //do whatever w/ the data
         }
      ]]>
    </mx:Script>
    <components:MyCustomComponent id="c2" data="{data}" />
</mx:Canvas>

(note this is psuedo code and probably full of typos as well)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜