开发者

Accessing Flex’s objects by id

开发者 https://www.devze.com 2023-01-06 12:24 出处:网络
I have a datagrid which has id=\"myGrid\" in my application, from it I call a component. Now from t开发者_运维技巧he component I can call parentDocument.myGrid.selectedIndex = 0; and it works fine.

I have a datagrid which has id="myGrid" in my application, from it I call a component. Now from t开发者_运维技巧he component I can call parentDocument.myGrid.selectedIndex = 0; and it works fine.

But I want to make the component reusable, and I would like to pass the ID to the component each time, so myGrid will change, how to properly send the ID to the component, and use it in the component?


I would extend the DataGrid to add the new property that you can pass in. When creating a new component, there is an option to "extend" an existing component; so just extend the DataGrid. This will give you all the properties of the DataGrid. The property can be something like this:

public var myParentDoc : UICpomponent;

However, since you didn't explain what you're doing, I'm not sure I completely understand how you're using parentDocument or for what purpose. Where in your DataGrid are you using parentDocument? In an eventListener? Or in an itemRenderer?


  1. create a new MXML component and put all your DataGrid code inside
  2. user the new component instead of the datagrid and assign different ids
0

精彩评论

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