我在 asp.net mvc 上使用 jqgrid。
我的观点:
$("#phoneGrid").jqGrid({
url: '/Demo/_PhoneChangeData',
datatype: 'json',
ajaxGridOptions: { contentType: 'application/json; charset=utf-8' },
serializeGridData: function (postData) {
if (postData.searchField === undefined)
postData.searchField = null;
if (postData.searchString === undefined)
postData.searchString = null;
if (postData.searchOper === undefined)
postData.searchOper = null;
return JSON.stringify(postData);
},
jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records",
cell:"cell",
id: "id"
},
postData:
{
accountNumber: "@Model.AccountNumber",
},
autoWidth: true,
shrinkToFit: false,
mtype: 'POST',
colNames: ['Phone Number', 'Update Date', 'Update Time'],
colModel: [
{ name: 'PhoneNumber', width:100, align: 'left' },
{ name: 'UpdateDate', width: 100, align: 'left' },
{ name: 'UpdateTime', width: 100, align: 'left' }],
rowNum: 10,
rowList: [],
pager: "#pagerphonedetail",
viewrecords: true,
rownumbers: true,
pgtext: null,
width: 346,
height: 232
});
我的控制器:
public ActionResult _PhonePopupChangeData(string accountNumber,
int page, int rows, string sidx, string sord,
bool _search, string searchField, string searchOper, string searchString)
{
var phdetail = query.GetPhoneUpdHistory(accountNumber);// returns a list
int recordsCount = phdetail.Count;
var viewData = phdetail.Select((p, index) => new TableRow
{
id = index + 1,
cell = new List<string> {
p.PhoneNumber, p.UpdateDate, p.UpdateTime
}
}).ToArray();
var jsonData = new
{
total = (recordsCount + rows - 1) / rows,
page = page,
records = recordsCount,
rows = viewData
};
return Json(jsonData, JsonRequestBehavior.AllowGet);
}
问题: 我的问题是,每次回发后(如果我在分页上单击下一步)网格中的行永远不会更新,屏幕截图显示它更新了页面编号,但我仍然得到网格的前 10 行,它永远不会更新。如果您不理解我的问题,请告诉我。