jqgrid does not submit reset page value on trigger

2019-05-18 16:15发布

I am triggering jqgrid reload on button click and also resetting the page value to '1' for my pagination to work correctly. But jqgrid submits the value present in the grid(if on 2nd page it sends a value of '2) and it also sends some additional parameters which were part of previous search. How can I avoid that please?

$('#delete').click(function() {
    var rowIds = msgGrid.jqGrid('getGridParam','selarrrow');
    $('#grid').setGridParam({url:'delete.html?rowIds=' + rowIds,
     page: '1'
    }); 
    $('#userGrid').trigger("reloadGrid");  
});

jQuery(function() {
  jQuery("#grid").jqGrid({
    url:'page.html',
    datatype: 'json',
    mtype: 'POST',
        .....  
    postData: { 
       totalRecords: function() { return $('#grid').getGridParam("records"); } 
        },
    rowNum: 25,
        .....
  });
});

When the grid is first loaded my url is page.html, but when user selects some rows and clicks delete, I am changing the url to delete.html with selected rows. The delete functionality deletes the selected rows and sends the latest data back to grid. Now if I click on refresh, it is still going to delete.html as my url is not changed. Also if user selects few rows before refresh, the selected rows data get deleted as the url is not changed...

标签: jquery jqgrid
1条回答
叛逆
2楼-- · 2019-05-18 16:47

You should change the page directly with page: 1 instead of postData: { page: '1' } (see here) or just use parameter [{page:1}] of reloadGrid (see here).

You don't wrote enough information about the sending some additional parameters which were part of previous search. If you use loadonce:true parameter then you have to reset datatype parameter to its original value (see here or here).

查看更多
登录 后发表回答