jqGrid获取所有行数据提交保存

function saveFun(){
	debugger;
	Supp.alert("专家保存按钮",Supp.alert.type.info);
	var rowSet = $("#jqGrid").jqGrid('getRowData');//获取或有行数据  json数组的形式
	Supp.ajax({
		url:ExpertExtract.saveOrUpdate,
		type:"post",
		async:true,
		dataType:"json",
		data: {
			data :JSON.stringify(rowSet)//将json数组转为String字符串
		},
		success:function(resp){
			if(resp){
				Supp.showSuccess("保存成功!");
			}else{
				Supp.showSuccess("保存失败!");
			}
			
		}
	});
	
	console.log(rowSet);
	
}

后端处理:

public OperResult<ExpertList> saveOrUpdate(HttpServletRequest request){
		String data = request.getParameter("data");
		JSONArray object = JSONArray.fromObject(data);//将String转json数组
		//JSONArray.toArray(object, ExpertList.class);
		@SuppressWarnings({ "unchecked", "deprecation" })
		List<ExpertList> lists=(List<ExpertList>)JSONArray.toList(object, ExpertList.class);//将json集合jArray放入list集合中,
		for(ExpertList s : lists){
			service.saveOrUpdate(s);
		}
		return OperResult.succeed(null);
		
	}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章