Forum
22:14
03/09/2009
Hi,
If you have multiselect set to true then you get a checkbox column. However, if you click anywhere on the row it checks and unchecks the checkbox.
For me personally, and now for my employeer this is a real usability bug. If you have a link in any column then clicking on the link checks and unchecks the checkbox for that row.
So I fixed and am submitting my fix incase any one wants the same thing or you are interested in incorporating it into the codebase.
I'm not entirely sure how to specify where the code is because suspect that the file is different for everyone based on what you select on download, but I will try.
I guess the method is a click event on the row. In my jquery.jqGrid.src.js it's line 2385
$(ts).before(grid.hDiv).click(function(e) {
then a ways down you have
in this code scb true if the target of the event was the checkbox
} else if ( !ts.p.multikey ) {
if(ts.p.multiselect && ts.p.multiboxonly) {
// this is good. This is the one we want
if(scb){$(ts).jqGrid("setSelection",ri,true,e);}
else {
....
frozen column code
....
// this is bad, this one says even if you did not click on the checkbox
// still select the row.
$(ts).jqGrid("setSelection",ri,true,e);
}
} else {
// this one is the same as the one above.
$(ts).jqGrid("setSelection",ri,true,e);
}
so what I did was change it to
} else if ( !ts.p.multikey ) {
if(ts.p.multiselect && ts.p.multiboxonly) {
// this is good. This is the one we want
if(scb){$(ts).jqGrid("setSelection",ri,true,e);}
else {
....
frozen column code
....
if(!ts.p.multiselectoncheckboxonly){
$(ts).jqGrid("setSelection",ri,true,e);
}
}
} else if(!ts.p.multiselectoncheckboxonly){
$(ts).jqGrid("setSelection",ri,true,e);
}
}
then in the gridoptions that pass in to the grid I simply set multiselectoncheckboxonly:true,
if you are using some other stuff like the multikey or maybe editing you may have to dig deeper, but this gets me where I need to be.
Raif
22:53
03/09/2009
Well, not much interest in this feature I guess, but I'm still interested. I found, perhaps, a better way to do this that doesn't break the selarrow array. scratch what I have above and do this. Inside of the setSelection method ~ 2645
if(!$t.p.multiselectoncheckboxonly ){
if ( ia === -1){
if(pt.className !== "ui-subgrid") { $(pt).addClass("ui-state-highlight").attr("aria-selected","true");}
stat = true;
$t.p.selarrrow.push($t.p.selrow);
} else {
if(pt.className !== "ui-subgrid") { $(pt).removeClass("ui-state-highlight").attr("aria-selected","false");}
stat = false;
$t.p.selarrrow.splice(ia,1);
tpsr = $t.p.selarrrow[0];
$t.p.selrow = (tpsr === undefined) ? null : tpsr;
}
$("#jqg_"+$.jgrid.jqID($t.p.id)+"_"+$.jgrid.jqID(pt.id))[$t.p.useProp ? 'prop': 'attr']("checked",stat);
}else if($(e.target).hasClass("cbox")){
if ( ia === -1){
stat = true;
$t.p.selarrrow.push($t.p.selrow);
}else{
stat = false;
$t.p.selarrrow.splice(ia,1);
}
$("#jqg_"+$.jgrid.jqID($t.p.id)+"_"+$.jgrid.jqID(pt.id))[$t.p.useProp ? 'prop': 'attr']("checked",stat);
}
basically what this does is if you have the prop multiselectoncheckboxonly set to true, then you can't set rows as "visually" selected. if you want the rows visually selected as well as checked then add the line
if(pt.className !== "ui-subgrid") { $(pt).addClass("ui-state-highlight").attr("aria-selected","true");}
and it's counter part, to the bottom part.
All I'm doing is wrapping the top part which is already part of the source in the if else clause and providing the multiselectoncheckboxonly functionality in the second part. Also I don't have any "frozen" columns so if you do you might have to mess with the next few lines as well.
r
08:09
Moderators
30/10/2007
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:
68 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