flex4.5 DataGrid 列中添加Button,事件函数中获取外部的方法、属性。
2012-03-22 20:24
405 查看
外部的方法和属性必须用public,内部列函数用
outerDocument 获得。
看例子吧:
//更新
public function updateData():void { _service = new RemotingConnection(_gatewayURL); _service.call("RemotingService.PlanConfiguration.deletePlanConfigurationData", new Responder(onUpdateDataResult,onFault),dgResult.selectedItem.id); }
//删除 public function delectData():void { _service = new RemotingConnection(_gatewayURL); _service.call("RemotingService.PlanConfiguration.deletePlanConfigurationData", new Responder(onDeleteDataResult,onFault), dgResult.selectedItem.id); }
1<s:DataGrid id="dgResult" width="100%" height="100%" dataProvider="{arr}">
2 <s:columns>
3 <s:ArrayList>
4 <s:GridColumn headerText="方案编号" dataField="id" width="65"/>
5 <s:GridColumn headerText="方案名称" dataField="name" width="65"/>
6 <s:GridColumn headerText="方案类型" dataField="type" width="65"/>
7 <s:GridColumn headerText="标题" dataField="tittle" width="38"/>
8 <s:GridColumn headerText="时间" dataField="date" width="70"/>
9 <s:GridColumn headerText="地点" dataField="site" width="38"/>
<s:GridColumn headerText="任务描述" dataField="describe" width="65"/>
<s:GridColumn headerText="执行单位" dataField="execute_unit" width="65"/>
<s:GridColumn headerText="协作单位" dataField="assist_unit" width="65"/>
<s:GridColumn headerText="发送单位" dataField="send_unit" width="65"/>
<s:GridColumn headerText="媒体附件" dataField="accessory" width="65"/>
<s:GridColumn headerText="操作">
<s:itemRenderer>
<fx:Component>
<s:GridItemRenderer>
<s:layout>
<s:HorizontalLayout verticalAlign="middle" />
</s:layout>
<fx:Script>
<![CDATA[
protected function btnEide_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
if(outerDocument.dgResult.selectedIndex != -1)
{
outerDocument.updateData();
}
}
protected function btnDelete_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
outerDocument.delectData();
}
protected function btnPreview_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
outerDocument.previewData();
}
]]>
</fx:Script>
<s:Button id="btnEide" label="编辑" click="btnEide_clickHandler(event)" />
<s:Button id="btnDelete" label="删除" click="btnDelete_clickHandler(event)" />
<s:Button id="btnPreview" label="预览" click="btnPreview_clickHandler(event)" />
</s:GridItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:GridColumn>
</s:ArrayList>
</s:columns>
</s:DataGrid>
outerDocument 获得。
看例子吧:
//更新
public function updateData():void { _service = new RemotingConnection(_gatewayURL); _service.call("RemotingService.PlanConfiguration.deletePlanConfigurationData", new Responder(onUpdateDataResult,onFault),dgResult.selectedItem.id); }
//删除 public function delectData():void { _service = new RemotingConnection(_gatewayURL); _service.call("RemotingService.PlanConfiguration.deletePlanConfigurationData", new Responder(onDeleteDataResult,onFault), dgResult.selectedItem.id); }
1<s:DataGrid id="dgResult" width="100%" height="100%" dataProvider="{arr}">
2 <s:columns>
3 <s:ArrayList>
4 <s:GridColumn headerText="方案编号" dataField="id" width="65"/>
5 <s:GridColumn headerText="方案名称" dataField="name" width="65"/>
6 <s:GridColumn headerText="方案类型" dataField="type" width="65"/>
7 <s:GridColumn headerText="标题" dataField="tittle" width="38"/>
8 <s:GridColumn headerText="时间" dataField="date" width="70"/>
9 <s:GridColumn headerText="地点" dataField="site" width="38"/>
<s:GridColumn headerText="任务描述" dataField="describe" width="65"/>
<s:GridColumn headerText="执行单位" dataField="execute_unit" width="65"/>
<s:GridColumn headerText="协作单位" dataField="assist_unit" width="65"/>
<s:GridColumn headerText="发送单位" dataField="send_unit" width="65"/>
<s:GridColumn headerText="媒体附件" dataField="accessory" width="65"/>
<s:GridColumn headerText="操作">
<s:itemRenderer>
<fx:Component>
<s:GridItemRenderer>
<s:layout>
<s:HorizontalLayout verticalAlign="middle" />
</s:layout>
<fx:Script>
<![CDATA[
protected function btnEide_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
if(outerDocument.dgResult.selectedIndex != -1)
{
outerDocument.updateData();
}
}
protected function btnDelete_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
outerDocument.delectData();
}
protected function btnPreview_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
outerDocument.previewData();
}
]]>
</fx:Script>
<s:Button id="btnEide" label="编辑" click="btnEide_clickHandler(event)" />
<s:Button id="btnDelete" label="删除" click="btnDelete_clickHandler(event)" />
<s:Button id="btnPreview" label="预览" click="btnPreview_clickHandler(event)" />
</s:GridItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:GridColumn>
</s:ArrayList>
</s:columns>
</s:DataGrid>
相关文章推荐
- 如何使用VC++ 2005 给ActiveX控件添加方法,属性,事件
- 这么详细的分类 VC/C++源代码网站你见过没有? VC/C++中的每一个方法,每一个操作,每一个头文件,每一个函数,每一个类.每一个属性,每一个事件都有相应的范例代码
- Uploadify 3.2 参数属性、事件、方法函数详解
- Uploadify 3.2 参数属性、事件、方法函数详解
- Uploadify 3.2 参数属性、事件、方法函数详解
- 获取对象的 RTTI 属性与事件的函数
- NGUI 给Button添加事件并调用用户函数
- js 获取函数的所有参数和遍历JavaScript某个对象所有的属性名称和值的方法
- delegate() 方法为指定的元素(属于被选元素的子元素)添加一个或多个事件处理程序,并规定当这些事件发生时运行的函数。 使用 delegate() 方法的事件处理程序适用于当前或未来的元素(比如
- 这么详细的分类 PHP源代码网站你见过没有? PHP中的每一个方法,每一个操作,每一个头文件,每一个函数,每一个类.每一个属性,每一个事件都有相应的范例代码
- jQuery动态添加li标签并添加属性和绑定事件方法
- Uploadify 3.2 参数属性、事件、方法函数详解
- 这么详细的分类 C++ 源代码网站你见过没有? C++ 中的每一个方法,每一个操作,每一个头文件,每一个函数,每一个类.每一个属性,每一个事件都有相应的范例代码
- c# 给button添加不规则的图片以及用pictureBox替代button响应点击事件的方法
- Uploadify 3.2 参数属性、事件、方法函数详解
- listview里的button事件添加方法
- jq在添加a链接时绑定事件,在方法中获取表格中的信息
- js获取某个控件的集合并添加属性或事件
- 如何给vb的UserControl添加属性、方法和事件?
- listview里的button事件添加方法