经过太多尝试我放弃并寻求帮助......我使用我在网络上找到的代码在客户端上执行编辑并将编辑原始发送到 asp.net 服务器。但我似乎无法在服务器上调用或从网格中获取数组(虽然我在使用调试器时看到了 Json 上的值)。所以我有两个问题。1. 我在“GridUpdateData”上放置了一个断点,但从未在客户端看到异常,也从未到达服务器。为什么 GridUpdateData 调用没有到达服务器?我怎样才能解决这个问题?2. 我需要在服务器上读取的变量是什么?/它是如何发送的?
谢谢,约翰。
客户端代码:
$(文档).ready(函数 () {
var updateDialog = {
url: "Default.aspx/GridUpdateData",
closeAfterEdit: true,
afterclickPgButtons: function (whichbutton, formid, rowid) {
$("#x2").select();
}
, modal: true
, onclickSubmit: function (params)
{
var ajaxData = {};
var gridId = $("#gridId");
var selectedRow = gridId.getGridParam("selrow");
rowData = gridId.getRowData(selectedRow);
ajaxData = { x2: x2 };
return ajaxData;
}
, width: "400"
};
$.jgrid.nav.addtext = "Add";
$.jgrid.nav.edittext = "Edit";
$.jgrid.nav.deltext = "Delete";
$.jgrid.edit.addCaption = "Add Contact";
$.jgrid.edit.editCaption = "Edit Contact";
$.jgrid.del.caption = "Delete Contact";
$.jgrid.del.msg = "Delete selected Contact?";
$("#gridId").jqGrid({
datatype: 'json',
mtype: 'POST',
colNames: ['x1', 'x2', 'x3'],
colModel: [
{ name: 'x1', index: 'x1', width: 40, editRow: true, sorttype: "string", align: 'left', editable: true, editrules: { required: true } },
{ name: 'x2', index: 'x2', width: 300, editRow: true, sorttype: "string", align: 'left', editable: true, edittype: 'text', editrules: { required: true } },
{ name: 'x3', index: 'x3', width: 200, editRow: true, sorttype: "string", align: 'left', editable: true, edittype: 'text', editrules: { required: true } }
],
pager: $('#gridPager'),
sortname: 'x2',
sortorder: "desc",
altRows: true,
viewrecords: true,
imgpath: '/Content/Themes/Redmond/Images',
caption: 'Equipment List',
autowidth: true,
ondblClickRow: function (rowid, iRow, iCol, e) {
$("#gridId").editGridRow(rowid, prmGridDialog);
}
}).navGrid('#gridPager',
{
edit: true, add: true, del: true, search: false, refresh: false
},
updateDialog,
updateDialog,
updateDialog
);
$("#gridId").jqGrid('clearGridData');
});
(我将网格字段更改为 X1-x3。)服务器代码:
公共静态无效GridUpdateData(){
}