Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable subgrid expansion for selected rows of jqGrid

Problem: jqGrid with subgirds. I want to disable the expand/collapse functionality for some rows of the main grid.

like image 301
Ankit Khanal Avatar asked May 27 '10 20:05

Ankit Khanal


3 Answers

I actually found a way:

grid.jqGrid('setGridParam',{
                afterInsertRow: function(rowid, aData, rowelem) {

                    var rowData = grid.getRowData(rowid);
                    if(**Condition**){
                        $('tr#'+rowid, grid)
                         .children("td.sgcollapsed")
                         .html("")
                         .removeClass('ui-sgcollapsed sgcollapsed');
                    }
                }
            });

There was a bit of a problem. The code @Frank removed the icon, but the 'click' event was still triggered. Trying to unbind the 'click' event doesn't seem to work, probably because it is attached later on ( maybe on gridComplete). Anyway, I figured that the click event is attached using one of the 'ui-sgcollapsed sgcollapsed' classes, so if you remove them, the event won't be attached.

Hope it helps.

like image 142
Madalin Stefirca Avatar answered Nov 03 '22 19:11

Madalin Stefirca


Add this to the gridConfig

afterInsertRow: function(rowid, aData, rowelem) {
    // Remove the subgrid plus button except for rows that have exceptions
    if (CONDITION) {
        $('#' + rowid).children("td.sgcollapsed").unbind().html("");
    }
},
like image 29
Frank Avatar answered Nov 03 '22 18:11

Frank


If you are trying to disable or hide the subgrids expand and collapse button then use this on loadcomplete,

jQuery("#GridTeableID").jqGrid('hideCol', "subgrid");
like image 23
PUBG Avatar answered Nov 03 '22 17:11

PUBG