1
獲取,編輯和刪除全部正常工作。但添加不會調用我的ActionResult方法。我正在使用內聯添加,它爲新記錄值顯示模態窗體。在最新的jqGrid版本中提供的pager/form方法似乎很少有這樣的例子。我在這裏添加/插入錯過了什麼?jqGrid添加行不起作用
HTML:
$("#grid").jqGrid({
url: 'ABC.Admin/CourseAdmin/GetLocationData/',
datatype: 'json',
jsonReader: { repeatitems: false },
mtype: 'GET',
colNames: ['Location Id', 'Name', 'Address Line 1'],
colModel: [
{ name: 'LocationId', index: 'LocationId', width: 40, key: true },
{ name: 'LocationName', index: 'LocationName', width: 150, editable: true },
{ name: 'AddressLine1', index: 'AddressLine1', width: 150, editable: true },
],
pager: jQuery('#pager'),
rowNum: 20,
sortname: 'Name',
sortorder: "asc",
viewrecords: true,
caption: '***Testing***',
height: 200,
loadonce: true, // needs to be true for client side paging to work
autowidth: true,
loadtext: 'Loading...'
})
$("#grid").jqGrid('navGrid', '#pager', { edit: true, add: true, del: true },
{ // edit options
url: 'ABC.Admin/CourseAdmin/SaveLocation/',
closeAfterEdit: true
},
{ // add
url: 'ABC.Admin/CourseAdmin/Create/'
},
{ //delete
url: 'ABC.Admin/CourseAdmin/DeleteLocation/',
closeOnEscape: true
}
);
控制器:
公衆的ActionResult創建(INT ID,字符串LOCATIONNAME,串addressLine1)
[HttpPost]
public ActionResult CreateLocation(string oper, string id, string locationName, string addressLine1) {
//Models.LocationProvider lp = new Models.LocationProvider();
//bool saved = lp.InsertLocation(location);
bool saved = false;
if (!saved)
{
Response.StatusCode = 500;
return Content("Record not saved!");
}
else
{
return Json(false);
}
}