我在主细节模式下使用 jqGrid。当我单击主网格中的一行时,我运行 SelectedRowHandler javascript 函数,我想更新详细信息网格但它不起作用。
调用选定的行处理程序并调用操作,但网格不会更新。
这是js
function SelectedRowHandler(rowId) {
var rowData = this.p.data[this.p._index[rowId]];
$.ajax({
type: "POST",
url: '/Invoice/invoiceitems2',
data: { invoiceId: rowData.Id },
datatype: "json",
success: function (data) {
$("#InvoiceItemsGrid").jqGrid("GridUnload");
var mygrid = $("#InvoiceItemsGrid")[0];
var myjsongrid = eval("(" + data.responseText + ")");
myjsongrid = null;
data = null;
},
viewrecords: true
});
return true;
}
ActionResult 是
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult InvoiceItems2(int invoiceId)
{
var response = new JqGridResponse();
var invoiceItems = _invoiceItemRepository.GetMany(p => p.InvoiceId == invoiceId);
foreach (var x in invoiceItems)
{
response.Records.Add(new JqGridRecord(Convert.ToString(x.InvoiceItemId), new InvoiceItemViewModel()
{
Id = x.InvoiceItemId,
PartNo = x.PartNo,
Description =
x.Description,
Quantity = x.Quantity,
Price = x.Price,
Total =
x.Quantity*x.Price
}));
}
return new JqGridJsonResult() {Data = response};
}
我将不胜感激任何帮助。