DataGrid更新数据时的一系列问题的解决
2011-04-28 21:28
267 查看
【问题描述】
一个表格,里面是员工的信息,可以通过update操作更新员工信息,但这一操作需要在表格下的表单中进行。
如上图所示,必须先按下update,然后在红色方框的表单中修改。现在希望能直接在表格里修改。
【方法】
1. 将DataGrid设置为editable
2. 增加事件itemEditEnd
3. 为事件itemEditEnd添加响应函数
其中employee[event.dataField] = (empDg.itemEditorInstance as mx.controls.TextInput).text;修改的是前端
employeeService.updateEmployee(employee);修改的是后端
4. 运行程序,可以直接在表格中修改了。
改成
【仍然存在的问题】
页面刷新后,smith_test又变回了smith
【分析】
页面刷新后,数据恢复到未修改的状态,说明后来的数据没有修改成功
【测试过程】
1. 打开Network Monitor,发现有2个响应
在DataGrid中修改后发现响应没有增加,说明employeeService.updateEmployee(employee);
这一句并没有被调用。
2. 代码定位到事件响应定义处,发现
<mx:DataGrid x="36" y="167" id="empDg" creationComplete="empDg_creationCompleteHandler(event)" dataProvider="{getEmployeesResult.lastResult}" width="751" includeIn="EmployeeAdd,EmployeeDetail,EmployeeUpdate,Employees" change.Employees="empDg_changeHandler(event)" x.Employees="36" y.Employees="148" x.EmployeeDetail="36" y.EmployeeDetail="151" x.EmployeeAdd="36" y.EmployeeAdd="151" x.EmployeeUpdate="36" y.EmployeeUpdate="151" editable="true" itemEditEnd.Employees="empDg_itemEditEndHandler(event)">
【原因】 原来是此函数仅在状态Employees中才响应,而编辑DataGrid时程序已经转入了EmployeeDetail状态
【修改】
itemEditEnd="empDg_itemEditEndHandler(event)"
测试修改后刷新页面,问题终于解决
一个表格,里面是员工的信息,可以通过update操作更新员工信息,但这一操作需要在表格下的表单中进行。
如上图所示,必须先按下update,然后在红色方框的表单中修改。现在希望能直接在表格里修改。
【方法】
1. 将DataGrid设置为editable
2. 增加事件itemEditEnd
3. 为事件itemEditEnd添加响应函数
protected function empDg_itemEditEndHandler(event:DataGridEvent):void { employee[event.dataField] = (empDg.itemEditorInstance as mx.controls.TextInput).text; employeeService.updateEmployee(employee); }
其中employee[event.dataField] = (empDg.itemEditorInstance as mx.controls.TextInput).text;修改的是前端
employeeService.updateEmployee(employee);修改的是后端
4. 运行程序,可以直接在表格中修改了。
改成
【仍然存在的问题】
页面刷新后,smith_test又变回了smith
【分析】
页面刷新后,数据恢复到未修改的状态,说明后来的数据没有修改成功
【测试过程】
1. 打开Network Monitor,发现有2个响应
在DataGrid中修改后发现响应没有增加,说明employeeService.updateEmployee(employee);
这一句并没有被调用。
2. 代码定位到事件响应定义处,发现
<mx:DataGrid x="36" y="167" id="empDg" creationComplete="empDg_creationCompleteHandler(event)" dataProvider="{getEmployeesResult.lastResult}" width="751" includeIn="EmployeeAdd,EmployeeDetail,EmployeeUpdate,Employees" change.Employees="empDg_changeHandler(event)" x.Employees="36" y.Employees="148" x.EmployeeDetail="36" y.EmployeeDetail="151" x.EmployeeAdd="36" y.EmployeeAdd="151" x.EmployeeUpdate="36" y.EmployeeUpdate="151" editable="true" itemEditEnd.Employees="empDg_itemEditEndHandler(event)">
【原因】 原来是此函数仅在状态Employees中才响应,而编辑DataGrid时程序已经转入了EmployeeDetail状态
【修改】
itemEditEnd="empDg_itemEditEndHandler(event)"
测试修改后刷新页面,问题终于解决
相关文章推荐
- [导入]关于DATAGRID数据更改时点2次/行号跟不准/失去焦点/丢失e等一系列问题的解决办法:
- Silverlight 解决 更新数据后 datagrid同步问题
- jquery 请求ie缓存,数据不更新的问题【ajax禁用缓存解决ie数据不更新的问题】
- 解决SpringBoot更新数据到MySQL乱码问题
- 解决IE11 vue +webpack 项目中数据更新后页面没有刷新的问题
- 关于extjs中的tabpanel的刷新等若干问题,解决tabpanel内页面刷新,更新数据等问题。
- 解决jQuery的EasyUI的datagrid数据表格中行的垂直居中问题。
- 解决jQuery的EasyUI的datagrid数据表格中行的垂直居中问题。
- hive的数据修改更新问题解决
- ListView中开启线程查询更新数据导致的ViewHolder错乱问题解决
- 高并发下解决更新数据丢失问题
- 解决SpringBoot更新数据到MySQL乱码问题
- 测试代码,解决java gui swing多线程界面假死、僵死问题,实现界面动态刷新,动态同步更新数据
- 解决SpringBoot更新数据到MySQL乱码问题
- 【解决方法】EasyUI DataGrid不显示滚动条时,没有数据的问题
- 关于easyui datagrid 大量数据加载时 出现假死问题的解决方法
- EF延迟加载机制导致的更新数据的时候有的更新有的没更新问题的解决
- 同步DataContext,解决linq to sql更新数据的问题
- 解决在拍照之后,Media数据没有及时更新问题
- 解决SpringBoot更新数据到MySQL乱码问题