在使列隐藏、显示、调整大小和重新排序后,我将 jqGrid 设置保存在 localStorage 中。一切都已完成,但colName
无法保存在localStorage
.
在我用于保存和加载网格的函数下方
function saveGrid(grid)
{
var gridData = $('#grid').jqGrid('getGridParam');
var gridDataAsString = JSON.stringify(gridData);
localStorage.setItem("GridParam", gridDataAsString);
getColumn();
}
function loadGrid()
{
var loadedGridDataAsString = localStorage.getItem("GridParam");
if (loadedGridDataAsString != null)
{
var loadedGridData = JSON.parse(loadedGridDataAsString);
$("#grid").jqGrid('setGridParam', loadedGridData);
$("#grid").trigger('reloadGrid');
}
}