//为数组添加一个方法,判断某个值是否存在于数组中 Array.prototype.in_array = function (e) { for (i = 0; i < this.length && this[i] != e; i++); return !(i == this.length); }
var array = new Array(); //数组中的Item var arr = { //"RFQID": $("#ID").val(), "RFQID": $(this).attr("rfqid"), "SiteCode": $(this).attr("site"), "ProcessID": $(this).attr("processid"), "ForecastLoading": $(this).val(), "SimulateNumber": 2, "MainRFQID": $("#ID").val() } array .push(arr); //将Item塞入数组
$.ajax({ type: "Post", processData: false, contentType: ‘application/json; charset=UTF-8‘, url: "/ReportSimulation/UpdateProcessForecastLoading", data: { list: arrObj }, beforeSend: function (xhr, setting) { setting.data = JSON.stringify(setting.data);//转为Json }, success: function (r) { if (r.Success) { alert("Success"); } else { alert("Error"); } } });
服务器接收:
public ActionResult UpdateProcessForecastLoading(List<ForecastProcessLoadingVM> list)
ForecastProcessLoadingVM 申明:
public class ForecastProcessLoadingVM { public Guid RFQID { get; set; } public string SiteCode { get; set; } public Guid ProcessID { get; set; } public string ProcessName { get; set; } public double? ForecastLoading { get; set; } public int SimulateNumber { get; set; } public Guid MainRFQID { get; set; } }
JQGrid中,直接将grid getRowData就可以传回了:
var gridData = $gridCAPEX.getRowData(); //var postData = JSON.stringify(gridData); //alert("JSON serialized jqGrid data:\n" + postData); var data = { ID: $("#ID").val(), NeedNewCAPEX: $("#NeedNewCAPEX").val(), CAPEXVMList: gridData }; $.ajax({ type: "Post", processData: false, contentType: ‘application/json; charset=UTF-8‘, url: "/BDFormPage/SaveCAPEX", data: data, beforeSend: function (xhr, setting) { setting.data = JSON.stringify(setting.data); }, success: function (r) { if (r.Success) { alert("Success"); } else { alert("Error"); } } });
时间: 2024-11-04 21:37:06