Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何在重新加载网格时保持高级多重搜索_Jquery_Jqgrid - Fatal编程技术网

Jquery 如何在重新加载网格时保持高级多重搜索

Jquery 如何在重新加载网格时保持高级多重搜索,jquery,jqgrid,Jquery,Jqgrid,我有一个jqgrid,它以设定的时间间隔重新加载自己,并使用多重搜索选项。一切都很好,除了重新加载时,我丢失了以前输入的所有过滤/搜索,所有数据都显示出来 如何在重新加载后保留任何筛选/搜索。代码如下。如有任何建议,敬请告知: jQuery(document).ready(function () { jQuery("#list").jqGrid({ datatype: 'json', url: 'GetWorkItems.ashx?

我有一个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);
        }
    }); 
jQuery(文档).ready(函数(){
jQuery(“#list”).jqGrid({
数据类型:“json”,
url:'GetWorkItems.ashx?view=MyActiveItems',
高度:“100%”,
滚动偏移量:0,
jsonReader:{
根:“行”,
第页:“第页”,
总计:“总计”,
记录:“记录”,
重复项:false,
细胞:“细胞”,
id:“id”,
用户数据:“用户数据”,
子网格:{
根:“行”,
重复项:对,
细胞:“细胞”
}
},
colNames:['''ID','TopParentID','Title','Assigned To','Status','Priority','Classification','infected 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},
{名称:'Title',索引:'Title',宽度:180},
{名称:'AssignedUser',索引:'AssignedUser',宽度:100,对齐:'center'},
{名称:'Status',索引:'Status',宽度:60,对齐:'center'},
{name:'Priority',index:'Priority',width:50,align:'center'},
{名称:'Category',索引:'Category',宽度:120,对齐:'center'},
{name:'AffectedUser',index:'AffectedUser',宽度:100,对齐:'center'},
{名称:'Tier',索引:'Tier',宽度:100,对齐:'center'},
{name:'LastModified',index:'LastModified',width:120,align:'center',formatter:'date',formattoptions:{srcformat:'Y-m-dh:i:s0',newformat:'m/d/Y H:i A'}
}],
寻呼机:“#寻呼机”,
rowNum:15,
宽度:980,
sortname:'Id',
排序器:“asc”,
viewrecords:是的,
自动宽度:正确,
gridview:没错,
有一次:是的,
ignoreCase:是的,
标题:“分配给我的所有活动工作项”,
OnSetrow:功能(id){
//在这里进行重定向
}
});
$.extend($.jgrid.search,{multipleSearch:true,multipleGroup:true,recreateFilter:true,overlay:0});
jQuery(“#list”).jqGrid('navGrid','#pager',{add:false,edit:false,del:false});
函数iconFormatter(单元格值、选项、行对象){
返回“”;
};
var interval=parseInt($(“#”)val();
设置超时(刷新网格,间隔);
函数refreshGrid(){
jQuery(“#list”).jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid');
设置超时(刷新网格,间隔);
}
}); 

当我们计算出
'setGridParam'时,{datatype:'json'})
是不需要的,所以应该被删除

嗯,我刚刚在我自己的项目上进行了测试,设置了多个搜索参数,然后触发了重新加载,保留了所有这些设置,默认情况下,网格会将所有搜索参数发回控制器。你为什么需要多重搜索?为什么需要在刷新时重置数据类型?我认为也没有必要使用
multipleSearch:true
。你应该能够有多个过滤器没有这个(我个人没有设置它)。您可能还想摆脱jsonReader,因为我也不认为这是必要的。应该有一大堆清晰的例子供你参考。最后,这是否让您走上了正确的道路?是的,我通过删除数据类型的重置,并像这样更改JSON读取器来实现:page:function(){return 1;},total:function(){return 1;},records:function(obj){if($.isArray(obj)){return obj.length;}if($.isArray(obj.items)){return obj.items.length;}返回0;}嗯,我不确定下面是否有什么实质性的答案…请输入数据类型的重置?这会起作用:)Thx!