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)
            {

            }        

 

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

 

转载于:https://www.cnblogs.com/ushou/p/3383794.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值