Get、Edit、およびDeleteはすべて正常に機能します。ただし、addはActionResultメソッドを呼び出しません。新しいレコード値のモーダルフォームを表示するインライン追加を使用しています。最新のjqGridリリースで提供されているpager/formメソッドでこれがどのように機能するかの例はほとんどないようです。ここに追加/挿入するために何が欠けていますか?
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
}
);
コントローラ:
public ActionResult Create(int id、string locationName、string 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);
}
}