I have a jqgrid with multiselect and multiPageSelection. My users can select different rows on different pages between ajax page calls. I've added a custom button and method to the pager to clear the selected rows regardless of page:
$("#grid").navButtonAdd('#pager', {
caption: "Clear",
title: "Clear Selection",
buttonicon: "ui-icon-circle-close",
onClickButton: function() {
$("#grid").setGridParam({ multiPageSelection: false });
$("#grid").resetSelection();
$("#grid").setGridParam({ multiPageSelection: true});
},
position: "first"
});
You can see I've had to set multiPageSelection to false, reset the selection and then set multiPageSelection back to true to make this work.
I tried
$("#grid").resetSelection();
and then one of:
$("#grid").setGridParam({ selarrrow: ""});
$("#grid").setGridParam({ selarrrow: []});
$("#grid").setGridParam({ selarrrow: {}});
$("#grid").setGridParam({ selarrrow: null});
None of them worked. Either they generated an error or the command was ignored and selarrrow still contained values.
resetSelection only clears the values on the current page if multiPageSelection is true.
Is there a jqgrid command to reset the selection regardless of multiPageSelect?
If I correctly understand your problem then you just use wrong way to reset array parameter selarrrow
(or other parameter like data
). The most easy way to do that consist of the usage of getGridParam
instead of setGridParam
. The call of getGridParam
without an additional parameter returns the reference to all internal parameters of jqGrid and you will be easy to replace any array parameter:
var $grid = $("#grid"), p = $grid.jqGrid("getGridParam"});
p.selarrrow = [];
Alternatively you can use
$("#grid").jqGrid("setGridParam", { selarrrow: [] }, true);
with the second parameter true
. The last way is a little more readable, but any usage of setGridParam
is slower as the usage of getGridParam
.