flex中使dataGrid每行都有button
2014-12-30 15:08
176 查看
使dataGrid中每行都有button,且在点击button时知道点击的是哪行的button。
代码如下:
自动生成的button的click方法没有在原页面上,所以无法调用dataGrid中selectedIndex,所以需要引用outerDocument.的方法,这样就能访问到外面的方法,此时可以删掉<mx:Button>中间的<fx:Script>,直接调用外面的方法了,外面的方法一定要定义为public类型,否则还会报错.
代码如下:
<mx:DataGrid id="dg" editable="true" color="0x323232" width="100%" height="450" rowCount="32" rowHeight="40" dataProvider="{dataIndicator}"> <mx:columns> <mx:DataGridColumn dataField="indexIndicator" width="50" headerText="序号" textAlign="center" editable="false"/> <mx:DataGridColumn dataField="INDICATOR_VALUE" headerText="指标值" editable="true"/> <mx:DataGridColumn editable="false" width="120" itemRenderer=""> <mx:itemRenderer> <fx:Component> <mx:HBox width="100" horizontalAlign="center" verticalAlign="top"> <mx:Button label="保 存" width="80" click="outerDocument.button1_clickHandler(event)"> <fx:Script> <![CDATA[ protected function button1_clickHandler(event:MouseEvent):void { // TODO Auto-generated method stub } ]]> </fx:Script> </mx:Button> </mx:HBox> </fx:Component> </mx:itemRenderer> </mx:DataGridColumn> </mx:columns> </mx:DataGrid>
自动生成的button的click方法没有在原页面上,所以无法调用dataGrid中selectedIndex,所以需要引用outerDocument.的方法,这样就能访问到外面的方法,此时可以删掉<mx:Button>中间的<fx:Script>,直接调用外面的方法了,外面的方法一定要定义为public类型,否则还会报错.
相关文章推荐
- (转)flex中DataGrid中itemRenderer的button的click调用方法问题
- Flex控件--AdvancedDataGrid实现列头过滤功能(顺便写了Button列、CheckBox列、ComboBox列等)
- Flex中DataGrid使用列中放Button
- flex――DataGrid中的固定序号
- Silverlight中Datagrid添加Button列用于控制单行对象
- FLEX 屏闭系统右键菜单,及在列表控件DataGrid/Tree/List上点右键时自动选择当前行
- Aligning labels in a Flex PopUpButton control’s pop up menu
- Flex 4.0 DataGrid
- Flex/Air将DataGrid数据导出为CSV/Excel格式
- Flex中如何动态生成DataGrid以及动态生成表头
- flex中datagrid列滚动锁定
- Flex 中 DataGridColumn 根据单列返回值,标红需要标红的显示数据
- Flex AdvancedDataGrid能够修改某一条背景颜色的继承方法
- Flex DataGrid中光标键的焦点控制例子
- Flex 2 DataGrid 分页代码
- Flex DataGrid组件
- FLEX DataGrid背景颜色调试
- Flex4 自定义Datagrid的itemRenderer和headerRenderer
- Flex 2 DataGrid 分页
- Flex的DataGrid中时间如何格式化