如何清除sidx&单击重新加载网格时的sord参数

时间:2015-03-27 09:22:40

标签: jquery jqgrid jqgrid-asp.net

我正在使用jqGrid。我已经实现了多列搜索,通过搜索工具栏(在服务器端完全处理)并使用虚拟滚动来加载记录。但是当我点击自动重新加载网格时,所有搜索字段中的搜索字段都消失了所以没有问题,但排序列的值仍然是sidx&所以,当我点击重新加载网格而不是获取新记录时,我正在对记录进行排序。有没有办法处理这个....?

           jQuery("#jqgrid").jqGrid({
                    url: 'http://localhost:7887/application/get',
                    mtype: 'GET',
                    datatype: "json",
                    colNames: ['AppId', 'Name', 'Rank'],
                    colModel: [
                        {name: 'AppId', key: true, width: 80,search: true, searchoptions: { searchOperators: true, sopt: ['gt', 'eq','lt'],} },
                        { name: 'Name', width: 150, search: true, sorttype: 'text', searchoptions: { sopt: ['eq', 'bw', 'ew','cn'] } },
                        { name: 'Rank', width: 350, search: true },
                    ],
                    width: 800,
                    rowNum: 100,
                    height: 180,
                    scroll: 1,
                    viewrecords: true,
                    gridview: true,
                    loadonce:false,
                    caption: "Loading data while scrolling",
                    onSelectRow: jqGrid_RowSelectd,
                    emptyrecords:"there are no records to display",
                    pager:"#gridpager"
                });

                $("#jqgrid").filterToolbar({ autosearch: true, searchOperators: true, sopt: ['gt', 'eq'] });
                $("#jqgrid").navGrid('#gridpager', { del: false, add: false, edit: false }, {}, {}, {}, { multipleSearch: true });
            });

1 个答案:

答案 0 :(得分:1)

您可以将beforeRefresh定义为navGrid的选项。所以你可以做以下的

$("#jqgrid").navGrid('#gridpager', { del: false, add: false, edit: false,
    beforeRefresh: function () {
        var p = $(this).jqGrid("getGridParam");
        p.sortname = "";
        p.sortorder = "asc";
    }
}, {}, {}, {}, { multipleSearch: true });
相关问题