Flex中DataGrid使用列中放Button
来源:互联网 发布:外贸免费cms系统 编辑:程序博客网 时间:2024/05/17 06:09
Flex 中使用DataGrid,让其中的某些列可以编辑,并在最后一列放按钮,单击保存修改。效果如下:
其中价格是可以编辑的,其他不可编辑。点击按钮之后将数据更新到服务器。代码如下:
<mx:DataGrid x="0" y="0" height="80%" width="100%" dataProvider="{DP}" id="producesell" editable="true"><mx:columns><mx:DataGridColumn headerText="名称" dataField="name" editable="false"/><mx:DataGridColumn headerText="数量" dataField="volume" editable="false"/><mx:DataGridColumn headerText="价格(元/千克)" dataField="price" editable="true"></mx:DataGridColumn><mx:DataGridColumn headerText="确认价格" editable="false"><mx:itemRenderer><fx:Component><mx:VBox><!--parentDocument很牛B的办法 --><s:Button label="确认" id="produceConfirmButton" width="50" click="parentDocument.produceConfirmButton_clickHandler(event)"/></mx:VBox></fx:Component></mx:itemRenderer></mx:DataGridColumn></mx:columns></mx:DataGrid>
editable="true"使DataGrid的每一列都可以编辑,如果某一列不想被编辑,如编号一般都不会允许编辑,就用editable="false"设定,这样单击某单元格,就可以编辑了,编辑完毕之后单击确认,提交到数据库。代码如下:public function produceConfirmButton_clickHandler(event:MouseEvent):void{var id:int=producesell.selectedItem.id;var str:String=producesell.selectedItem.price;if(str==null||str=="")Alert.show("请输入价格","提示");else{str=str.replace(/^\s*|\s*$/g,"");if(Number(str).toString()!="NaN"){var price:Number=(Number)(str);commUserservice.updatePriceFromWarehouse(id,price);}else{Alert.show("价格必须为数字","提示");}}}注意:click="parentDocument.produceConfirmButton_clickHandler(event)",因为我将Button的clickHandler代码块移动到了主<fx:Script>标记中。dataProvider指定DataGrid的数据源,可以为一个XML文件,也可以用一个ArrayCollection对象,后者比较灵活,ArrayCollection中存放一系列对象,对象的属性的个数不能少于DataGrid的列数,不然没法给每一列绑定数据域,可以将ArrayCollection中存放的对象的某些属性赋给DataGrid的列,其它保留。dataField="name" 指定该列显示的数据来自哪里,此处为ArrayCollection中存放的对象的name属性。
- Flex中DataGrid使用列中放Button
- Flex中使用DataGrid
- DataGrid中使用Button操作
- Flex DataGrid中添加Label,Button,CheckBox,ComboBox
- FLEX中使用AS动态创建DataGrid
- flex中ComboBox和datagrid的使用
- Flex中sys:DataGrid标签的使用
- flex中DataGrid(表格)的使用
- 使用DataGrid- Flex分页
- FLEX 中的DataGrid使用
- flex datagrid渲染使用
- Flex Datagrid的使用
- 使用radion button选择datagrid的行(在datagrid中使用radio buttons)
- FLEX在datagrid中的itemreader中渲染combobox使用outerDocument
- flex 中Button文本换行
- FLEX中自定义button样式
- FLex中 DataGrid导出Excel
- flex中DataGrid中的checkbox
- [c\c++]C++环境下使用C函数
- [转]进程和线程的区别
- IT学习论坛和视频网站
- Oracle监听器和服务名的配置
- tomcat 能够启动 并且能够用http://127.0.0.1:8080访问 但是不能用http://localhost:8080访问的解决办法。
- Flex中DataGrid使用列中放Button
- 为什么析构函数定义为虚函数
- CGContext小记
- Hdu 4679 树型DP
- 你是我的蓝颜知己
- PHP基础15-统计关键字个数
- 去掉图片旋转时的锯齿
- 从某个构造函数调用重载版的另一个构造函数
- 懒加载