zoukankan      html  css  js  c++  java
  • ExtJs批量更新

    昨天这个批量更新花了我不少时间,特记下来,省得以后忘记。

    批量更新的逻辑是这样的。

    获取Store中需要更新的行,把行放入数组,然后再将数组转化为Json字符串,Json字符串传后后台后,解析为实体列表,然后就遍历并批量更新啦。

    批量更新主要代码如下:

    1,获取Store更新行,批量提交到数据库。

                            //获取Store更新行,批量提交到数据库
                            var result = new Array();
                            for (var i = 0; i < wdpsDTOStore.data.length; i++) {
                                var model = wdpsDTOStore.getAt(i);
                                if (model.dirty) {
                                    result.push(model.data);
                                }
                            }
                            if (result.length == 0) {
                                JsHelper.ShowError('修改行为空,请重新操作!');
                                return;
                            }
    
                            Ext.Ajax.request({
                                url: virupath + '/LogisticsMgr/UpdateWDps',
                                params: {
                                    'strJsonWdps': Ext.encode(result)
                                },
                                success: function(form, action) {
                                    var result = Ext.util.JSON
                                                 .decode(form.responseText);                                
                                    if (result.success) {
                                        JsHelper.ShowWarning('数据提交成功!');
                                        LoadStore();
                                    } else {
                                        JsHelper.ShowError(result.msg);
                                    }
                                },
                                failure: function(form, action) {                             
                                    JsHelper.ShowError('提交异常,请稍后再试!');
                                }
                            });

    2,在后台中解析并遍历。

                List<WdpsDTO> listWdpsDTO = FormatJsonExtension.JSONStringToList<WdpsDTO>(Request["strJsonWdps"]);
                foreach (WdpsDTO item in listWdpsDTO)
                {
    
                }        

    现在看很简单,但当时走了一些弯路,不说了,但对我来说也是一个宝贵的经验。

  • 相关阅读:
    c# EPPlus读取Excel里面的时间字段时,1900-01-01转成了1899-12-31
    c# MongoDB分页辅助类,支持多条件查询
    c#比较器辅助类
    mysql创建存储过程动态SQL语句
    MySQL数据库之DML(数据操作语言)
    MySQL数据库之DDL(数据定义语言)
    MySQL数据库的基本语法
    MySQL入门基础知识
    scala入门基础学习
    推荐算法杂点
  • 原文地址:https://www.cnblogs.com/ushou/p/3383794.html
Copyright © 2011-2022 走看看