开发者

jqGrid with multiselect on, how to turn off checkbox checking when row is selected

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开发者_如何学C.

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?


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

Add above line of code on gridComplete function


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);
}


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');
},


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; 
    },


add init method

  <ClientSideEvents GridInitialized="grdInit">

  function grdInit()
  { 
    var myGrid = $("#myGrid"); 
    myGrid.jqGrid('hideCol', 'cb');
  }


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.


    beforeSelectRow: function(rowid, e){
    if(e.srcElement.type == "checkbox"){
     return true;
    }
    return false;
   },


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;
    }


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜