将grid数据提交到后台保存

前台选择
function Resultdata2(jsondata) {
        var listRecord = new Array();
        if (jsondata instanceof Ext.data.Store) {

            Ext.each(jsondata.data.items, function (record) {


                listRecord.push(record.data);
            });
        }
        else if (jsondata instanceof Array) {
            Ext.each(jsondata, function (record) {

                listRecord.push(record.data);
            });
        }//decode
        return Ext.encode(listRecord);
    }

提交代码
       var selectedRecords = contract_selectItem_gridBudget.getSelections();
                    var storedata = Resultdata2(selectedRecords);
                    Ext.Ajax.request({
                        url: 'AjaxPage/WooYuSuan/ContYusuanManager.aspx?cmd=savedata',
                        method: 'POST',
                        params: {
                            contId: contract_htbuild_gethtid,
                            data: storedata
                        },
                        success: function (response, options) {
                            if (response.responseText = "OK") {
                                Ext.MessageBox.hide();
                                woo.util.wooAlert("保存成功!");
                                _store.reload();
                            }
                        }
                    })

//后台代码
  var Rows = PageUtility.GetRequestString("data");
            var isupdate = PageUtility.GetRequestBoolean("isupdate");
            var json = JsonObject.Parse(Rows);
            for (int i = 0; i < json.Count; i++)
            {
                var info2 = new Woo.Model.WOO_CONT_YUSUAN();
                var json0 = json[i];
                var jsonobj = json0 as JsonObject;
                if (jsonobj != null)
                {
                    //预算ID
                    info2.YUSUAN_ID = Convert.ToInt32((jsonobj["ID"] as JsonPrimitive).Value);
                    //事业部ID
                    info2.SHIYEBU_ID = Convert.ToInt32((jsonobj["SHIYEBU_ID"] as JsonPrimitive).Value);
                    info2.YEAR = Convert.ToInt32((jsonobj["YEAR"] as JsonPrimitive).Value);
                    info2.CONT_ID = contID == 0 ? Woo.Utility.LoginUtility.GetCurrentUserID() : contID;
                    info2.AMOUNT = Convert.ToDecimal((jsonobj["AMOUNT"] as JsonPrimitive).Value);
                    //info2.ZHANYONG_AMOUNT = Convert.ToDecimal((jsonobj["ZHANYONG_AMOUNT"] as JsonPrimitive).Value);
                    //info2.YUSUAN_YUE = Convert.ToDecimal((jsonobj["YUSUAN_YUE"] as JsonPrimitive).Value);
                    info2.ZHANYONG_AMOUNT = 0;
          //执行添加到数据库方法
                    Woo.BLL.WooContract.ContYuSuan.Insert(info2);
                   

                }
            }

你可能感兴趣的:(Extjs)