这是我的JQGrid的代码
$("#vendor_match_grid").jqGrid({
url: $("#hdnWebSericeAPIURL").val() + "/api/PRAClubbedVendor/ViewClubbedVendorMasterData/",
datatype: 'json',
mtype: 'GET',
height: 500,
colModel: [
{ name: 'Vendor Number', index: 'Vendor_Number', editable: false },
{ name: 'Vendor Name', index: 'Vendor_Name', editable: true },
{ name: 'Clubbed Vendor Name', index: 'Clubbed_Vendor_Name', editable: true },
{ name: 'Phone Number', index: 'Phone_Number', editable: true },
{ name: 'Fax Number', index: 'Fax_Number', editable: true },
{ name: 'Email', index: 'Email', editable: true },
{ name: 'Street', index: 'Street', editable: true },
{ name: 'City', index: 'City', editable: true },
{ name: 'Country', index: 'Country', editable: true },
{ name: 'Region', index: 'Region', editable: true },
{ name: 'Is Active', index: 'IsActive', editable: true, edittype: 'select', editoptions: { value: { 'True': 'Active', 'False': 'InActive' } } },
{ name: 'TableFlag', index: 'TableFlag', editable: false, hidden: true }],
pager: '#vendor_match_pagernav',
rowNum: 20,
rowList: [20, 50, 100],
viewrecords: true,
sortable: true,
sortname: "TableFlag",
sortorder: "desc",
search: true,
searchOperators: true,
stringResult: true,
closeAfterSearch: true,
caption: 'Clubbed Vendor Match',
emptyrecords: 'No records to display',
autowidth: true,
loadComplete: function () { },
onSelectRow: function (rowID) { }
}).navGrid('#vendor_match_pagernav', { edit: false, add: false, del: false, search: true, refresh: true }, {}, {}, {}, { closeAfterSearch: true });
现在,我正在使用此代码添加自定义按钮
$("#vendor_match_grid").jqGrid('navButtonAdd', '#vendor_match_pagernav', {
caption: "Add vendor",
id: "btnAddVendor",
onClickButton: function () {}
});
在onClickFunction中,我打开一个弹出窗口,添加一些数据并进行ajax调用,并且在AJAX的成功中,我需要重新加载网格。但数据没有重新加载。 jqGrid变空。我没有使用loadonce,我的数据不是本地的。我可能做错了什么?
****更新**** 这是我的AJAX电话
$.ajax({
url: $('#hdnWebSericeAPIURL').val() + '/api/PRAClubbedVendor/FinalizeClubbedVendorMasterData/',
type: "POST",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(clubbedVendorDataObject),
dataType: "json",
success: function (response) {
$("#vendor_match_grid").jqGrid("setGridParam", { datatype: "json" })
.trigger("reloadGrid", [{ current: true, page: 1 }]);
//$("#vendor_match_grid").trigger('reloadGrid');
},
error: function (response) {
}
});
答案 0 :(得分:0)
您可以在点击添加到网格中的自定义按钮时触发重新加载方法调用。