可以使用itemEditBegin和itemEditEnd事件来检查传向或回传自itemEditor的数据。如,可以格式化与验证数据。
<?xml version="1.0"?>
<!-- itemRenderers\events\BeginEditEventAccessEditor.mxml -->
<!-- http://yecon.blog.hexun.com/30375399_d.html-->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.events.DataGridEvent;
import mx.controls.NumericStepper;
import mx.collections.ArrayCollection;
import mx.controls.listClasses.IDropInListItemRenderer;
[Bindable]
private var myDP:ArrayCollection = new ArrayCollection([
{Artist:'Pavement', Album:'Slanted and Enchanted', Price:11.99},
{Artist:'Pavement', Album:'Crooked Rain, Crooked Rain', Price:10.99},
{Artist:'Pavement', Album:'Wowee Zowee', Price:12.99},
{Artist:'Pavement', Album:'Brighten the Corners', Price:11.99},
{Artist:'Pavement', Album:'Terror Twilight', Price:11.99}
]);
// Handle the itemEditBegin event.
private function modifyEditedData(event:DataGridEvent):void
{
// Get the name of the column being editted.
var colName:String = myDataGrid.columns[event.columnIndex].dataField;
if(colName=="Price")
{
// Handle the event here.
event.preventDefault();
// Creates an item editor.
myDataGrid.createItemEditor(event.columnIndex,event.rowIndex);
// All item editors must implement the IDropInListItemRenderer interface
// and the listData property.
// Initialize the listData property of the editor.
IDropInListItemRenderer(myDataGrid.itemEditorInstance).listData =
IDropInListItemRenderer(myDataGrid.editedItemRenderer).listData;
// Copy the cell value to the NumericStepper control.
myDataGrid.itemEditorInstance.data = myDataGrid.editedItemRenderer.data;
// Add 20 percent to the current price.
NumericStepper(myDataGrid.itemEditorInstance).value +=
0.2 * NumericStepper(myDataGrid.itemEditorInstance).value;
}
}
]]>
</mx:Script>
<mx:DataGrid id="myDataGrid" dataProvider="{myDP}"
editable="true"
itemEditBegin="modifyEditedData(event);"
rowHeight="60">
<mx:columns>
<mx:DataGridColumn dataField="Artist" />
<mx:DataGridColumn dataField="Album" width="130" />
<mx:DataGridColumn dataField="Price" editorDataField="value">
<mx:itemEditor>
<mx:Component>
<mx:NumericStepper stepSize="0.01" maximum="500"/>
</mx:Component>
</mx:itemEditor>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
</mx:Application>
`````````````````````````````````````````````````````````````````````
<?xml version="1.0"?>
<!-- itemRenderers\events\EndEditEventFormatter.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >
<mx:Script>
<![CDATA[
import mx.controls.TextInput;
import mx.events.DataGridEvent;
import mx.events.DataGridEventReason;
import mx.formatters.NumberFormatter;
import mx.collections.ArrayCollection;
[Bindable]
private var initDG:ArrayCollection = new ArrayCollection([
{Artist:'Pavement', Album:'Slanted and Enchanted',
Price:11.99},
{Artist:'Pavement', Album:'Brighten the Corners',
Price:11.99 }
]);
// Define the number formatter.
private var myFormatter:NumberFormatter=new NumberFormatter();
// Define the eventlistner for the itemEditEnd event.
public function formatData(event:DataGridEvent):void {
// Check the reason for the event.
if (event.reason == DataGridEventReason.CANCELLED)
{
// Do not update cell.
return;
}
// Get the new data value from the editor.
var newData:String=
TextInput(event.currentTarget.itemEditorInstance).text;
// Determine if the new value is an empty String.
if(newData == "") {
// Prevent the user from removing focus,
// and leave the cell editor open.
event.preventDefault();
// Write a message to the errorString property.
// This message appears when the user
// mouses over the editor.
TextInput(myGrid.itemEditorInstance).errorString=
"Enter a valid string.";
return;
}
// For the Price column, return a value
// with a precision of 2.
if(event.dataField == "Price") {
myFormatter.precision=2;
TextInput(myGrid.itemEditorInstance).text=
myFormatter.format(newData);
}
}
]]>
</mx:Script>
<mx:DataGrid id="myGrid"
dataProvider="{initDG}"
editable="true"
itemEditEnd="formatData(event);" >
<mx:columns>
<mx:DataGridColumn dataField="Artist"/>
<mx:DataGridColumn dataField="Album"/>
<mx:DataGridColumn dataField="Price"/>
</mx:columns>
</mx:DataGrid>
</mx:Application>
分享到:
相关推荐
同时,DataGrid可以配置为可编辑,通过editable属性控制,配合itemEditBegin、itemEditEnd事件,可以实现数据验证和保存。 5. **扩展功能** - **分组功能**:通过设置groupField属性,DataGrid可以对数据进行分组...
这两种方法均与DataGrid组件的基本属性和事件相关。 第一种方法是通过设置DataGrid的`editable`属性为`true`,并禁止`itemEditBegin`事件的触发来防止编辑器的创建。这种方式是基于事件处理机制实现的。在DataGrid...
nodejs010-nodejs-cryptiles-0.2.2-1.el6.centos.alt.noarch.rpm
免费JAVA毕业设计 2024成品源码+论文+数据库+启动教程 启动教程:https://www.bilibili.com/video/BV1SzbFe7EGZ 项目讲解视频:https://www.bilibili.com/video/BV1Tb421n72S 二次开发教程:https://www.bilibili.com/video/BV18i421i7Dx
基于麻雀搜索算法优化的深度置信网络(SSA-DBN)参数调整与数据分类预测——以隐藏层节点、迭代次数和学习率为优化目标的MATLAB实现,基于麻雀搜索算法优化深度置信网络(SSA-DBN)的数据分类预测 优化参数为隐藏层节点、迭代次数和学习率 利用交叉验证抑制过拟合问题 matlab代码, ,SSA-DBN; 参数优化; 隐藏层节点; 迭代次数; 学习率; 交叉验证; 过拟合抑制; MATLAB代码,基于SSA-DBN优化的数据分类预测方法:参数优化与过拟合抑制
BeTheme第一次发布于2014年5月21日,自那时以来,已有数以百万计的人下载了BeTheme,其评分为4.8。这个主题是WooCommerce支持的,在此帮助下,您可以制作一个电子商务网站,还可以制作博客、新闻和其他类型的网站。BeTheme 21.5.6 wordpress主题模板特点:放大器支撑多用途主题500+预制件演示单击演示安装移动友好型主题联络表格7支持自转滑块。
基于S7-200智能控制与组态王4x3界面的书架式堆垛立体车库系统设计与应用,基于S7-200和组态王4x3书架式堆垛式立体库立体车库 ,S7-200; 组态王4x3; 书架式堆垛式立体库; 立体车库,基于S7-200与组态王4x3的立体车库系统
1、文件内容:pykde4-akonadi-4.10.5-6.el7.rpm以及相关依赖 2、文件形式:tar.gz压缩包 3、安装指令: #Step1、解压 tar -zxvf /mnt/data/output/pykde4-akonadi-4.10.5-6.el7.tar.gz #Step2、进入解压后的目录,执行安装 sudo rpm -ivh *.rpm 4、安装指导:私信博主,全程指导安装
基于28379D的异步电机无速度传感器控制:MD500与MD500E滑模同步调制代码研究,各种代码md500代码,异步电机,基于28379D,带无速度传感器控制,参数辨识,同步调制等功能。 还有md500e代码,滑模无感代码,逆变整流代码 ,核心关键词:md500代码; 异步电机; 28379D; 无速度传感器控制; 参数辨识; 同步调制; md500e代码; 滑模无感控制; 逆变整流代码。,基于28379D的MD500电机异步控制系统与参数辨识软件
"可再生能源驱动的热电联供微网经济运行优化研究:基于具体文献的程序复现与MATLAB粒子群算法应用",含可再生能源的热电联供型微网经济运行优化 有具体文献 程序复现 MATLAB粒子群算法 ,核心关键词: 可再生能源; 热电联供型微网; 经济运行优化; 具体文献; 程序复现; MATLAB粒子群算法。,含可再能源热电联供型微网运行优化策略复现于特定文献中的MATLAB模型研究。
1、文件内容:pyserial-2.6-6.el7.rpm以及相关依赖 2、文件形式:tar.gz压缩包 3、安装指令: #Step1、解压 tar -zxvf /mnt/data/output/pyserial-2.6-6.el7.tar.gz #Step2、进入解压后的目录,执行安装 sudo rpm -ivh *.rpm 4、安装指导:私信博主,全程指导安装
finishBitmap.jpg
"英博尔控制器调速软件全面升级,引领行业新风尚",英博尔控制器调速软件全新 ,英博尔; 控制器; 调速软件; 全新,英博尔控制器调速软件全新升级
电机定子模态频率计算方法及公式在Excel表格中的应用,电机定子模态频率计算公式,公式法,exl表格 ,电机定子模态频率计算公式; 公式法; EXL表格,电机定子模态频率计算方法及公式法在Excel表格中的应用
一、项目简介 包含:项目源码、数据库脚本等,该项目附带全部源码可作为毕设使用。 二、技术实现 jdk版本:1.8 及以上 ide工具:IDEA或者eclipse 数据库: mysql5.5及以上 后端:spring+springboot+mybatis+maven+mysql 前端: vue , css,js , elementui 三、系统功能 1、系统角色主要包括:管理员、用户 2、系统功能 主要功能包括: 用户登录注册 首页 个人中心 修改密码 个人信息 用户管理 管理员管理 问卷管理 题目管理 题目统计 问卷调查管理 新闻资讯管理 轮播图管理 问卷调查 新闻资讯 个人中心 问卷调查记录 后台管理 详见 https://flypeppa.blog.csdn.net/article/details/143189415
免费JAVA毕业设计 2024成品源码+论文+数据库+启动教程 启动教程:https://www.bilibili.com/video/BV1SzbFe7EGZ 项目讲解视频:https://www.bilibili.com/video/BV1Tb421n72S 二次开发教程:https://www.bilibili.com/video/BV18i421i7Dx
1、文件内容:pulseaudio-esound-compat-10.0-6.el7_9.rpm以及相关依赖 2、文件形式:tar.gz压缩包 3、安装指令: #Step1、解压 tar -zxvf /mnt/data/output/pulseaudio-esound-compat-10.0-6.el7_9.tar.gz #Step2、进入解压后的目录,执行安装 sudo rpm -ivh *.rpm 4、安装指导:私信博主,全程指导安装
免费JAVA毕业设计 2024成品源码+论文+数据库+启动教程 启动教程:https://www.bilibili.com/video/BV1SzbFe7EGZ 项目讲解视频:https://www.bilibili.com/video/BV1Tb421n72S 二次开发教程:https://www.bilibili.com/video/BV18i421i7Dx
一种基于Lifelogging视频的文本标签生成模型.pdf
MATLAB仿真:MIMO系统FLMS算法的优化与实现,一个mimo系统的flms算法的MATLAB仿真 ,Mimo系统; FLMS算法; MATLAB仿真,"MIMO系统FLMS算法MATLAB仿真"