我正在寻找有关此问题的任何线索,并找到Jqgrid on Edit operation sends “add” as oper=“add” why?。奥列格说,这是一个错误,它已修复但我使用内联编辑时遇到了同样的问题。我正在使用jqGrid 4.4.1。
在我的情况下,当我添加一行时会发生此问题,保存然后尝试编辑它。单击“保存”以保存更改后,查询字符串将显示oper=add
这是我的脚本供参考。我不认为它很漂亮,因为我还在第二天学习这个精彩的插件。
$(function () {
var grid = $("#list");
grid.jqGrid({
url: "@Url.Action("GetClassList", "Setup")",
datatype: "json",
height: 220,
width: 800,
colNames: ["Code", "Name", "Duration"],
colModel: [
{ name: "Code", index: "Code", width: 120, editable: true, key: true },
{ name: "Name", index: "Name", width: 250, editable: true },
{ name: "Duration", index: "Duration", width: 120, editable: true }
],
rowNum: 10,
rowList: [10, 20, 30],
pager: '#listPager',
sortname: "Code",
viewrecords: true,
sortorder: "desc",
multiselect: false,
subGrid: true,
editurl: "@Url.Action("UpdateClass", "Setup")",
caption: "Class Information",
subGridRowExpanded: function(subgrid_id, row_id) {
var subgrid_table_id, pager_id;
subgrid_table_id = subgrid_id+"_t";
pager_id = "p_"+subgrid_table_id;
$("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table><div id='"+pager_id+"' class='scroll'></div>");
var classCode = grid.jqGrid("getCell", row_id, "Code");
var http_get_url = "@Url.Action("GetClassScheduleList", "Setup", new { id = "_CC_PH_" })";
http_get_url = http_get_url.replace("_CC_PH_", classCode);
var http_post_url = "@Url.Action("UpdateClassSchedule", "Setup", new { id = "_CC_PH_" })";
http_post_url = http_post_url.replace("_CC_PH_", classCode);
jQuery("#"+subgrid_table_id).jqGrid({
url: http_get_url,
datatype: "json",
prmNames: {id: "rid"},
colNames: ["", "Day", "Start Time", "Block", "Room", "Is Selected"],
colModel: [
{ name: "Num", index: "Num", width:0, hidden: true, key: true },
{ name: "Day", index: "Day", width: 120, editable: true, edittype: "select", editoptions: { value: "Sunday:Sunday;Saturday:Saturday;Monday:Monday;Tuesday:Tuesday;Wednesday:Wednesday;Thursday:Thursday;Friday:Friday" }},
{ name: "Start Time", index: "Start Time", width: 120, align: "right", editable: true},
{ name: "Block", index: "Block", width: 70, align: "right", editable: true},
{ name: "Room", index: "Room", width: 70, align: "right", editable: true},
{ name: "Is Selected", index: "Is Selected", width: 100, align: "right", editable: true, edittype: "checkbox", editoptions: { value:"Yes:No" }}
],
rowNum:20,
pager: pager_id,
sortname: 'Num',
sortorder: "asc",
multiselect: false,
editurl: http_post_url,
height: '100%',
});
jQuery("#"+subgrid_table_id).jqGrid('navGrid',"#"+pager_id,{edit: false, add: false, del: false, search: false },{reloadAfterSubmit: true})
jQuery("#"+subgrid_table_id).jqGrid('inlineNav',"#"+pager_id)
},
subGridRowColapsed: function(subgrid_id, row_id) {
// this function is called before removing the data
//var subgrid_table_id;
//subgrid_table_id = subgrid_id+"_t";
//jQuery("#"+subgrid_table_id).remove();
}
});
jQuery("#list").jqGrid('navGrid', "#listPager", { edit: false, add: false, del: false, search: false },{reloadAfterSubmit: true});
jQuery("#list").jqGrid('inlineNav', "#listPager");
});
答案 0 :(得分:2)
试试这段代码
serializeRowData: function(postData){
// new row id is "new_row"
postData.oper = postData.id == "new_row" ? "add" : "edit";
return postData;
}