Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jqGrid - Unselect row on click

Tags:

jquery

jqgrid

How can I unselect a row on click? I tried this:

beforeSelectRow: function(rowid, e) {
    if ($(this).getGridParam('selrow') == rowid) {
        return false;
    } else {
        return true;
    }
}

But only selection works, if I click on a selected row it does nothing.

like image 616
lucasdc Avatar asked Dec 11 '13 16:12

lucasdc


2 Answers

Instead of return false try:

$("#myGrid").jqGrid("resetSelection");

So your code would be:

beforeSelectRow: function (rowid) {
    if ($(this).jqGrid("getGridParam", "selrow") === rowid) {
        $(this).jqGrid("resetSelection");
    } else {
        return true;
    }
}
like image 178
FastTrack Avatar answered Nov 03 '22 10:11

FastTrack


Try this

    onSelectRow: function(id, rowid){
        if(id && id!==lastsel3){
            jQuery('#NAME_GRID').jqGrid('saveRow',lastsel3); 
            lastsel3=id;
        }           
    },  

please declare lastsel3 = null;

like image 25
cavalsilva Avatar answered Nov 03 '22 11:11

cavalsilva