Forum
03:11
Moderators
30/10/2007
Hello,
Currently no, but you can play little with this using onSelectRow event.
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
03:56
Moderators
30/10/2007
Hello,
Try with the option multikey - see docs.
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
13:42
29/07/2009
I also want to get the behavior you describe, Markus. Multikey didn't do quite what I wanted, but for the limited case I need, I got it to work by doing three things:
1. calling hideCol(”cb”) to remove the checkboxes
2. suppressing the browser's default handling of shift clicks with:
$(table).mousedown(function(e) { if (e.shiftKey) return false; });
3. modifying grid.base.js to handle standard mouse behaviors like in file explorer and the grids from extjs and dojo
Replace line 1710 of grid.base.js in 3.5-beta with this:
if (!e.ctrlKey && !e.shiftKey) // click clears selection
$(ts).resetSelection();
if (e.shiftKey && ts.p.selrow && ts.p.selrow != ptr[0].id) { // grow selection on shift
var i = $(ts.rows).index($(”#” + ts.p.selrow));
var j = $(ts.rows).index($(”#” + ptr[0].id));
if (i > j) { var tmp = i; i = j; j = tmp; }
for (var k = i; k <= j; ++k) {
ptr = $(ts.rows).slice(k, k + 1);
if(!ptr.hasClass(”ui-state-highlight”)) // don't remove current selections
$(ts).setSelection(false, true, ptr);
}
else {
$(ts).setSelection(false, true, ptr);
}
Jonathan
16:38
29/07/2009
Version 1.8 of jquery ui.selectable is scheduled to provide support for ctrl and shift click:
http://dev.jqueryui.com/ticket/4205
http://dev.jqueryui.com/ticket/2946
Will be nice to see it in jqGrid too!
Cheers,
Jonathan
14:45
20/03/2009
Or, without having to modify grid.base:
add to options: gridComplete: function() { $(".cbox").shiftSelect(); }, add elsewhere: jQuery.fn.shiftSelect = function() { var checkboxes = this; var lastSelected; var executing = false; jQuery(this).click( function(event) { if (executing) return; if ( !lastSelected ) { lastSelected = this; return; } if ( event.shiftKey ) { var selIndex = checkboxes.index(this); var lastIndex = checkboxes.index(lastSelected); /* * if you find the "select/unselect" behavior unseemly, * remove this assignment and replace 'checkValue' * with 'true' below. */ var checkValue = lastSelected.checked; if ( selIndex == lastIndex ) { return true; } executing = true; var end = Math.max(selIndex,lastIndex); var start = Math.min(selIndex,lastIndex); for(i=start;i<=end;i++) { if (checkboxes[i].checked != checkValue) $(checkboxes[i]).click(); } executing = false; } lastSelected = this; }); }
shiftSelect lifted from: http://clownsinmycoffee.net/20.....th-jquery/
17:30
30/07/2009
Here's another one (I posted a more complex variant a few weeks ago - tony has since added the event parameter to the beforeSelectRow handler, which makes it much cleaner now).
Just set this as the beforeSelectRow handler (it will take care of shift and ctrl clicks in the "expected" manner).
var grid = $(e.target).closest("table.ui-jqgrid-btable");
var ts = grid[0], td = e.target;
var scb = $(td).hasClass("cbox");
if ((td.tagName == 'INPUT' && !scb) || td.tagName == 'A') {
return true;
}
var sel = grid.getGridParam('selarrrow');
var selected = $.inArray(sid, sel) >= 0;
if (e.ctrlKey || (scb && (selected || !e.shiftKey))) {
grid.setSelection(sid,true);
} 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(row.id, false);
}
}
} else if (!selected) {
grid.resetSelection();
}
if (!selected) {
grid.setSelection(sid,true);
} else {
var osr = grid.getGridParam('onSelectRow');
if ($.isFunction(osr)) {
osr(sid, true);
}
}
}
}
Mark
05:48
Moderators
30/10/2007
Just delete my post, Sorry
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
50 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66