3

I am using a jqGrid with multiselect put on. That works but I have a side effect which I would like to get rid off. Whenever someone clicks on a row the checkbox also alters its checked state. I would like to leave that out.

I tried this:

onSelectRow: function(row) { return false; }

and setting

beforeSelectRow: function(rowid, e) { return true; },

If I set this to false I get the desired behavior but then I also don't get any selected id's anymore via

jqGrid('getGridParam', 'selarrrow');

Anyone has an idea to fix this?

skaffman
  • 398,947
  • 96
  • 818
  • 769
Kris van der Mast
  • 16,343
  • 8
  • 39
  • 61

9 Answers9

8
$("#Grid_ID").jqGrid('hideCol', 'cb');

Add above line of code on gridComplete function

sth
  • 222,467
  • 53
  • 283
  • 367
Dipesh
  • 89
  • 2
  • I was gonna downvote this for not working with the new jqgrid, but it's 7 years old so you can keep your points. – catbadger Nov 03 '17 at 16:44
2
beforeSelectRow: function (rowid, e)        
{
    var $myGrid = $(this),
    i = $.jgrid.getCellIndex($(e.target).closest('td')[0]),
    cm = $myGrid.jqGrid('getGridParam', 'colModel');
    return (cm[i].name === 'cb');
},
Kris van der Mast
  • 16,343
  • 8
  • 39
  • 61
2

I had a case where I had a bunch of actions that were triggered by selecting cells and I didn't want the row to be selected.

I check the column number in the onCellSelect function and toggle the checkbox selection back for columns other than the first select column

if (iCol > 1) {
    $(grid).jqGrid('setSelection', rowid, false);
}
Justin Moore
  • 827
  • 10
  • 12
1

I tried awattar's approach but found srcElement was undefined. I used this instead:

    beforeSelectRow: function(rowid, e){ 
      var td = e.target;
      var index = $.jgrid.getCellIndex(td);
      if(index == 1){ 
        return true; 
      }
      return false; 
    },
Bob
  • 11
  • 1
1

add init method

  <ClientSideEvents GridInitialized="grdInit">

  function grdInit()
  { 
    var myGrid = $("#myGrid"); 
    myGrid.jqGrid('hideCol', 'cb');
  }
Mio
  • 11
  • 2
0

I was able to accomplish that by checking the column ID provided to the onSelect event handler. If it's any column other than the first, return false. I had to do it in a couple of event handlers in order to get the preferred behavior.

Rakesh Malik
  • 36
  • 1
  • 5
0
    beforeSelectRow: function(rowid, e){
    if(e.srcElement.type == "checkbox"){
     return true;
    }
    return false;
   },
Lloyd Powell
  • 18,270
  • 17
  • 87
  • 123
awattar
  • 265
  • 1
  • 2
  • 9
0

Try below one. Below code helps me to resloved that issue. With the help of this u are not able to click onto the grid.

beforeSelectRow: function(rowid, e) {
        return false;
    }
Pravin
  • 1
  • 3
-1

jqGrid is designed to work this way; do you have a good reason for not wanting to display the checkboxes?

Justin Ethier
  • 131,333
  • 52
  • 229
  • 284