So following up to my own post… after studying the grid code I found a way to do it – although its something of a hack, and rather fragile.
If beforeSelectRow could be passed the event object, and the column ix, I think I could do everything I want without any trickery.
For anyone else interested in a grid that supports shift-click to select ranges, ctrl-click to toggle rows, and handles clicks on editable fields smartly, the code follows. To use it set “multiselect:true,beforeSelectRow:function(){return false;}” in the grid options, and then add the handler as follows:
$(mygrid).bind(“click”,$(mygrid),multiSelectHandler);
where multiselectHandler is:
function multiSelectHandler(e) {
var grid = e.data;
var ts = grid[0], td = e.target;
var scb = $(td).hasClass(“cbox”);
var ptr = $(td).parents(“tr.jqgrow”);
if (!ptr.length || td.tagName == 'INPUT' || td.tagName == 'A') {
return true;
}
var sel = grid.getGridParam('selarrrow');
var sid = ptr[0].id;
var selected = $.inArray(sid, sel) >= 0;
if (e.ctrlKey || (scb && (selected || !e.shiftKey))) {
grid.setSelection(false,true,ptr);
} else {
if (e.shiftKey) {
var six = grid.getInd( sid);
var min = six, max = six;
$.each(sel, function() {
var ix = grid.getInd( this);
if (ix < min) min = ix;
if (ix > max) max = ix;
});
while (min <= max) {
var row = ts.rows[min++];
var rid = row.id;
if (rid != sid && $.inArray(rid, sel)<0) {
grid.setSelection( false, false, $(row));
}
}
} else if (!selected) {
grid.resetSelection();
}
if (!selected) {
grid.setSelection( false, true, ptr);
} else {
var osr = grid.getGridParam('onSelectRow');
if ($.isFunction(osr)) {
osr(sid, true);
}
}
}
}