itemRender---之outerDocument : 使用itemRender 和item Editor時想要訪問外部變量或方法的關鍵字

You use the <mx:Component> tag to define an inline item renderer or item editor in an MXML file.

The <mx:Component> tag defines a new scope within an MXML file, where the local scope of the item renderer or item editor is defined by the MXML code block delimited by the <mx:Component> and </mx:Component> tags. To access elements outside of the local scope of the item renderer or item editor, you prefix the element name with the outerDocument keyword.

For example, you define one variable named localVar in the scope of the main application, and another variable with the same name in the scope of the item renderer. From within the item renderer, you access the application's localVar by prefixing it with outerDocument keyword, as the following example shows:
Flex代碼




One use of the outerDocument keyword is to initialize the data provider of a control within the inline item editor. For example, you can use a web service, or other mechanism, to pass data into the application, such as the list of U.S. states. You can then initialize all ComboBox controls that are used as item editors from a single property of the application that contains the list of U.S. states.

MXML Syntax

The <mx:Component> tag has the following syntax:

<mx:Component id="" className="" >

... child tags

... </mx:Component>

You cannot create an empty <mx:Component></mx:Component> tag; you must define at least one child tag within the <mx:Component></mx:Component> tags.

The id property lets you specify an identifier for the inline component so that you can use it as the source for a data binding expression.

The className property lets you specify the name of the class generated by Flex for the inline component so that you can reference the elements of the component in ActionScript. For more information, see the Using Item Renderers and Item Editors chapter in the Flex Developer's Guide book.



thaks:http://blog.csdn.net/tingqier/archive/2008/10/17/3090326.aspx
Flex代碼
 

from:http://blog.minidx.com/2008/05/10/837.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章