1. $.map
1 function btnUpdate1_click() { 2 var grid = BUI.getControl(‘grid1‘); 3 var selections = grid.getSelection(); 4 if (selections.length == 0) { 5 dfAlert(getRes(‘请先选择记录‘)); 6 return; 7 } 8 var p = $.map(selections, function(a) { 9 return { 10 ‘PK_GUID‘: a.PK_GUID, 11 ‘ISVALID‘: $(‘#ISVALID1‘).val() 12 } 13 }); 14 if (confirm(getRes(‘确定要更新选定的记录么?‘))) { 15 dfGetData(‘DynamicForm.DA.Form_MES_T_LINEMATERIALDA.UpdateISVALID‘, { 16 DF_FORMNAME: ‘Form_MES_T_MO‘, 17 data: BUI.JSON.stringify(p) 18 }, function(data) { 19 BUI.getControl(‘grid1‘).get(‘store‘).load(); 20 }); 21 } 22 }
2.
1 public DataGridVM UpdateISVALID(DFDictionary entity) 2 { 3 var data = JsonSerializeHelper.DeserializeObject<List<Dictionary<string, string>>>(entity["data"]); 4 if (data == null) 5 { 6 throw new WFException("无效的参数data".GetRes()); 7 } 8 var user = Util.GetCurrentUser().UserName; 9 using (var db = Pub.DB) 10 { 11 db.Execute("update MES_T_WPMATERIAL set ISVALID=@ISVALID,LastModifyTime=@LastModifyTime,LastModifyUser=@LastModifyUser where PK_GUID=@PK_GUID", data.Select(a => new 12 { 13 ISVALID = a["ISVALID"], 14 PK_GUID = a["PK_GUID"], 15 LastModifyUser = user, 16 LastModifyTime = DateTime.Now 17 }).ToList()); 18 } 19 20 return new DataGridVM(); 21 }
原文:https://www.cnblogs.com/cherry1022/p/15001191.html