Hey there!
I've been working with JQGrid a lot, and would recommend it to everyone. The one feature I don't really like is the built in multiselect which doesnt use special keys like shift and ctrl, doesnt give you much control and forces checkboxes to be shown.
I would like to implement my own multiselect as follows: In onSelectRow- check if shift or ctrl is held add the row id to an array and select it in the grid. if none are held, clear the array and add the new row id and select it in the grid.
This is simple enough to implement, except i need an event in the onSelectRow to check if the keys are held. I would prefer not to attach a keydown and keyup event on the main document itself.
onSelectRow: function (id) {
event=???
if (!event.shiftKey && !event.ctrlKey) {
}
else {
}
}
Regards, Byron Cobb.
EDIT: Solution -
Following Olegs input, I have done the following.
- Set
multiselect: true
in the grid definition - Hidden the checkbox column in
gridComplete
by setting$("#myGrid").jqGrid('hideCol', 'cb');
- Checked for the ctrl key myself(not using multikey:"ctrlKey") before the select and clearing the selection if no ctrl key is pressed.
- Later using the selection array when needed -
var SelectedRows = $("#myGrid").jqGrid('getGridParam', 'selarrrow');
beforeSelectRow: function (rowid, e) {
if (!e.ctrlKey) {
$("#myGrid").resetSelection();
}
return true;
},