$("#list2").jqGrid({
url: ctx + '/JSONData',
datatype: "json",
colNames: ['Inv No', 'Date', 'Client', 'Amount', 'Tax', 'Total', 'Notes'],
colModel: [
{ name: 'id', index: 'id', width: 55 },
{ name: 'invdate', index: 'invdate', width: 90 },
{ name: 'name', index: 'name asc, invdate', width: 100 },
{ name: 'amount', index: 'amount', width: 80, align: "right" },
{ name: 'tax', index: 'tax', width: 80, align: "right" },
{ name: 'total', index: 'total', width: 80, align: "right" },
{ name: 'note', index: 'note', width: 150, sortable: false }
],
rowNum: 10,
rowList: [10, 20, 30],
pager: '#pager2',
sortname: 'id',
mtype: "post",
viewrecords: true,
reloadAfterSubmit: true, //成功保存記錄後重新加載grid數據
sortorder: "desc",
caption: "JSON 實例"
});
添加屬性reloadAfterSubmit: true,
添加 / 更新 / 刪除 jqgrid中的某項後調用方法:
$("#list2").resetSelection(); // 取消表格選中記錄
$("#list2").trigger("reloadGrid");// 刷新整個列表