Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
multiselect checks box when you click on any part of the row
17/07/2012
22:14
Avatar
Raif
Member
Members
Forum Posts: 17
Member Since:
03/09/2009
sp_UserOfflineSmall Offline

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

28/08/2012
22:53
Avatar
Raif
Member
Members
Forum Posts: 17
Member Since:
03/09/2009
sp_UserOfflineSmall Offline

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

29/08/2012
08:09
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

Forum Timezone: Europe/Sofia

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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information