$("#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");// 刷新整个列表