我有一个jqgrid,它在设定的时间间隔内重新加载,并使用多个搜索选项。一切都很好,除非重新加载时我丢失了之前输入的所有过滤/搜索并显示所有数据。
如何在重新加载后继续进行任何过滤/搜索。代码如下。任何建议表示赞赏:
jQuery(document).ready(function () {
jQuery("#list").jqGrid({
datatype: 'json',
url: 'GetWorkItems.ashx?view=MyActiveItems',
height: "100%",
scrollOffset: 0,
jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
cell: "cell",
id: "Id",
userdata: "userdata",
subgrid: {
root: "rows",
repeatitems: true,
cell: "cell"
}
},
colNames: ['', 'ID', 'TopParentID', 'Title', 'Assigned To', 'Status', 'Priority', 'Classification', 'Affected User', 'Support Group', 'Last Modified'],
colModel: [
{ name: 'Icon', index: 'Icon', align: 'right', width: 18, sortable: false, formatter: iconFormatter, search: false },
{ name: 'Id', index: 'Id', width: 45, sorttype: 'int', firstsortorder: 'desc' },
{ name: 'TopParentId', index: 'TopParentId', width: 65, align: 'center', sorttype: 'int', hidden: true },
{ name: 'Title', index: 'Title', width: 180 },
{ name: 'AssignedUser', index: 'AssignedUser', width: 100, align: 'center' },
{ name: 'Status', index: 'Status', width: 60, align: 'center' },
{ name: 'Priority', index: 'Priority', width: 50, align: 'center' },
{ name: 'Category', index: 'Category', width: 120, align: 'center' },
{ name: 'AffectedUser', index: 'AffectedUser', width: 100, align: 'center' },
{ name: 'Tier', index: 'Tier', width: 100, align: 'center' },
{ name: 'LastModified', index: 'LastModified', width: 120, align: 'center', formatter: 'date', formatoptions: { srcformat: 'Y-m-d H:i:s0', newformat: 'm/d/Y h:i A' }
}],
pager: '#pager',
rowNum: 15,
width: 980,
sortname: 'Id',
sortorder: 'asc',
viewrecords: true,
autowidth: true,
gridview: true,
loadonce: true,
ignoreCase: true,
caption: 'All Active Work Items Assigned To Me',
onSelectRow: function (id) {
//doing a redirect here
}
});
$.extend($.jgrid.search, { multipleSearch: true, multipleGroup: true, recreateFilter: true, overlay: 0 });
jQuery("#list").jqGrid('navGrid', '#pager', { add: false, edit: false, del: false });
function iconFormatter(cellvalue, options, rowObject) {
return '<img src="./images/' + cellvalue + '" alt="workitem" />';
};
var interval = parseInt($("#<%=hidRefreshInterval.ClientID %>").val());
window.setTimeout(refreshGrid, interval);
function refreshGrid() {
jQuery("#list").jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid');
window.setTimeout(refreshGrid, interval);
}
});
答案 0 :(得分:1)
我们发现不需要'setGridParam', { datatype: 'json' })
所以应该删除。