创建或编辑后,网格没有动态更新。请在我的脚本下方建议任何解决方案。我已启用刷新:true ,但网格仍未刷新。
//加载网格
$(function () {
$("#grid").jqGrid({
url: "/MVC/GetGrid",
datatype: 'json',
mtype: 'Get',
colNames: ['Id', 'Task Name', 'Task Description', 'Target Date', 'Severity', 'Task Status'],
colModel: [
{ key: true, hidden: true, name: 'Id', index: 'Id' },
{ key: false, name: 'TaskName', index: 'TaskName', editable: true },
{ key: false, name: 'TaskDescription', index: 'TaskDescription', editable: true },
{ key: false, name: 'TargetDate', index: 'TargetDate', editable: true, formatter: 'date', formatoptions: { newformat: 'd/M/y' }, datefmt: 'd-M-Y', editrules: { required: true }, editoptions: { dataInit: function (el) { setTimeout(function () { $(el).datepicker(); }, 200); } } },
{ key: false, name: 'Severity', index: 'Severity', editable: true, edittype: 'select', editoptions: { value: { 'L': 'Low', 'M': 'Medium', 'H': 'High' } } },
{ key: false, name: 'TaskStatus', index: 'TaskStatus', editable: true, edittype: 'select', editoptions: { value: { 'A': 'Active', 'I': 'InActive' } } },
],
pager: '#pager',
rowNum: 10,
rowList: [10, 20, 30, 40],
height: '100%',
viewrecords: true,
loadonce: true,
caption: 'Error Grid',
emptyrecords: 'No records to display!',
jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
id: "0"
},
autowidth: true,
multiselect: false
}).navGrid('#pager', { edit: true, add: true, del: true, search: true, refresh: true },
//Edit
{
zindex: 100,
url: '/MVC/Edit',
closeOnEscape: true,
closeAfterEdit: true,
recreateForm: true,
afterComplete: function (response) {
if (response.responseText) {
alert(response.responseText);
}
}
},
//Add
{
zindex: 100,
url: '/MVC/Create',
closeOnEscape: true,
closeAfterAdd: true,
recreateForm: true,
afterComplete: function (response) {
if (response.responseText) {
alret(response.responseText);
}
}
},
//Delete
{
zindex: 100,
url: '/MVC/Delete',
closeOnEscape: true,
closeAfterDelete: true,
recreateForm: true,
msg: "Are you sure you want to delete this hierarchy..?",
afterComplete: function (response) {
if (response.responseText) {
alret(response.responseText);
}
}
}).navButtonAdd('#pager', {
caption: "Excel", onClickButton: function () {
DataGrid.jqGrid('excelExport', { url: '/MVC/ExportToExcel' });
},
position: "last",
buttonicon: "ui-icon-extlink"
});
});