outerDocument : 使用itemRender 和item Editor时想要访问外部量的关键字
来源:互联网 发布:中金金网交易软件 编辑:程序博客网 时间:2024/05/22 01:31
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:
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
// Variable in the Application scope.
[Bindable]
public var localVar:String="Application localVar";
// Data includes URL to album cover.
private var initDG:Array = [
{ Artist:'Pavement', Album:'Slanted and Enchanted', Price:11.99,
Cover:'http://localhost:8100/f15/slanted.jpg'},
{ Artist:'Pavement', Album:'Brighten the Corners', Price:11.99,
Cover:'http://localhost:8100/f15/brighten.jpg'}
];
]]>
</mx:Script>
<mx:DataGrid id="myGrid" dataProvider="{initDG}"
variableRowHeight="true">
<mx:columns>
<mx:DataGridColumn dataField="Artist"/>
<mx:DataGridColumn dataField="Album"/>
<mx:DataGridColumn dataField="Cover">
<mx:itemRenderer>
<mx:Component>
<mx:VBox>
<mx:Script>
<![CDATA[
// Variable in the renderer scope.
public var localVar:String="Renderer localVar";
]]>
</mx:Script>
<mx:Text id="albumName" width="100%" selectable="false" text="{data.Album}"/>
<mx:Image id="albumImage" height="45" source="{data.Cover}"/>
<mx:TextArea text="{'Renderer localVar= ' + localVar}"/>
<mx:TextArea text="{'App localVar= ' + outerDocument.localVar}"/>
</mx:VBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn dataField="Price"/>
</mx:columns>
</mx:DataGrid>
</mx:Application>
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.
- outerDocument : 使用itemRender 和item Editor时想要访问外部量的关键字
- itemRender---之outerDocument : 使用itemRender 和item Editor时想要访问外部变量或方法的关键字
- flex使用的outerDocument
- flex4 outerDocument的使用介绍
- Flex 4的Item Renderer和Item Editor也是(必须)使用的halo的组件
- FLEX中使用itemRenderer调用父页面的方法使用关键字outerDocument
- outerDocument 使用
- DataGrid的itemreader中使用outerDocument
- FLEX中使用outerDocument
- FLEX中使用outerDocument
- FLEX中使用outerDocument
- flex在使用itemrender时,再次刷新数据时itemrender错乱问题
- Item 6: 当auto推导出一个不想要的类型时,使用显式类型初始化的语法
- Effective Modern C++ : Item 6 -> 当auto推断出不想要的类型时,使用显式类型初始化语法
- DataGrid中itemRender的用法--解决item中组件显示的问题
- Flex DataGrid中获得外部对象 outerDocument
- 诡异的itemRender
- FLEX中应用itemRenderer调用父页面的办法应用关键字outerDocument
- ASP.NET AJAX自定义应用程序服务的服务器端实现
- DirectShow开发音视频聊天程序
- 一种加密档案文件格式方案的设计思路
- mouse_event
- 几个常用的WINDOWS消息的值
- outerDocument : 使用itemRender 和item Editor时想要访问外部量的关键字
- 优化数据量大的表创建索引篇
- Excel导入数据到SQL数据库
- JAVA几个常见错误简析
- 小程序演示 C# 3.0 语法新特性
- vc小技巧---2
- IA-32 保护模式内存管理
- 关于Tomcat5.X中文问题的解决方法
- vc小技巧---1