代码之家  ›  专栏  ›  技术社区  ›  Ein2012

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

  •  0
  • Ein2012  · 技术社区  · 9 年前

    我使用的是jqGrid。我已经实现了多列搜索,通过搜索工具栏(完全在服务器端处理),并使用虚拟滚动来加载记录。但当我单击重新加载网格时,prams中的所有搜索字段都会自动消失,所以这没有问题,但排序列的值仍然存在,即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 回复  |  直到 9 年前
        1
  •  1
  •   Oleg    9 年前

    您可以定义 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 });