问题可以概括为当单击数据网格中的项目时,文本区域显示项目的值,但这里的组件是分开的,因此需要调度事件。
My mxml component file :
<?xml version="1.0" encoding="utf-8"?>
<mx:DataGrid xmlns:mx="http://www.adobe.com/2006/mxml" itemClick="itemClickEvent(event);" creationComplete="init()">
<mx:Metadata>
[Event(name="IdSelected", type="one.IdEvent")]
</mx:Metadata>
<mx:Script>
<![CDATA[ import genericReport.*;
import crewUtilization.*;
import utils.*;
import studies.*;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.controls.Alert;
import mx.events.ListEvent;
private function itemClickEvent(event:ListEvent):void
{
var _study:Object=event.currentTarget.selectedItem.study;
dispatchEvent(new IDEvent(_ID));
}
]]>
</mx:Script>
<mx:columns>
<mx:DataGridColumn dataField="name" />
<mx:DataGridColumn dataField="userId" />
</mx:columns>
</mx:DataGrid>
///////////////////////////////////////// /////////////
这是我的主要 MXML 应用程序文件:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:custom="*">
<mx:TitleWindow label="Scenario Creation" xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:ns1="ccCreation.*">
<mx:Label text="CC CREATION" width="100%" />
<mx:VBox width="100 %" styleName="scenariovboxStyle">
<custom:studySelector id="dg" />
</mx:VBox>
</mx:TitleWindow>
</mx:Application>