我需要在jqgrid中自动刷新服务器中的数据10分钟。 刷新后我需要零售过滤,排序,子网格展开,页面,选定行(多个)。
我可以保留除页面和选定行之外的所有内容。在这里我只能做页面或选定的行。无法保留两者。只有一个适合我。
代码
jQuery("#tblCompletedPriceList").jqGrid({
url: $('#tblCompletedPriceList').attr("RequestUrl"),
datatype: "json",
mtype: "Get",
hoverrows: false,
colNames: CompletedColName,
colModel: CompletedColModel,
id: 'PriceListID',
localReader: { id: 'PriceListID' },
prmNames: { id: "PriceListID" },
rowNum: 10,
hidegrid: false,
rownumbers: true,
pager: '#CompletedPriceListGridPager',
viewrecords: true,
caption: "Completed Price List Queue",
height: 'auto',
scrollOffset: 0,
gridview: true,
shrinkToFit: true,
autoencode: true,
loadonce: true,
ignoreCase: true,
multiselect: true,
subGrid: true,
enableClear: true,
loadComplete: function () {
UnBlockUI();
var $this = $(this);
var selRowIds = jQuery('#tblCompletedPriceList').jqGrid('getGridParam', 'selarrow');
postfilt = $this.jqGrid('getGridParam', 'postData').filters;
postsord = $this.jqGrid('getGridParam', 'postData').sord;
postsort = $this.jqGrid('getGridParam', 'postData').sidx;
postpage = $this.jqGrid('getGridParam', 'postData').page;
var selRowIds = jQuery('#tblCompletedPriceList').jqGrid('getGridParam', 'selarrrow');
if ($this.jqGrid("getGridParam", "datatype") === "json") {
setTimeout(function () {
$this.jqGrid("setGridParam", {
datatype: "local",
postData: { filters: postfilt, sord: postsord, sidx: postsort },
search: true
});
$this.trigger("reloadGrid", [{ page: postpage }]);
}, 15);
}
if (expandedids != "") {
$("#tblCompletedPriceList").jqGrid('expandSubGridRow', expandedids);
expandedids = "";
}
if (selRowIds.length < 1) {
return false;
} else {
var i, count;
for (i = 0, count = selRowIds.length; i < count; i++) {
jQuery('#tblCompletedPriceList').jqGrid('setSelection', selRowIds[i], false);
}
}
},
beforeRequest: function () {
$("#tblCompletedPriceList tr:has(.sgexpanded)").each(function () {
expandedids = $(this).attr('id');
});
}
});
重新加载
window.setTimeout(refreshGrid, 600000);
function refreshGrid() {
$('#tblCompletedPriceList').setGridParam({ datatype: 'json' }).trigger("reloadGrid");
window.setTimeout(refreshGrid, 600000);
}