0

我有一个 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);
        }
    }); 
4

1 回答 1

1

正如我们发现'setGridParam', { datatype: 'json' })不需要的,所以应该删除。

于 2013-03-12T16:27:54.720 回答