Disable subgrid expansion for selected rows of jqGrid
Asked Answered
I

4

7

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

Indifferentism answered 27/5, 2010 at 20:8 Comment(0)
G
6

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.

Gnomon answered 15/9, 2011 at 9:31 Comment(0)
P
3

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("");
    }
},
Pasho answered 22/6, 2010 at 19:34 Comment(1)
As Madalin mentions, this only removes the icon. Users can still click into it, meaning the functionality still exists.Soil
G
1

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

jQuery("#GridTeableID").jqGrid('hideCol', "subgrid");
Godsey answered 19/11, 2013 at 5:20 Comment(1)
This should be the answer. Thanks!Harriott
H
0

Unfortunately there is no jqGrid API for this. You will have to wait until the grid is created and then, perhaps from the loadComplete event, you will need to manually loop over all rows and disable selected ones.

If you inspect the DOM elements that compose the grid you can probably figure out a way to remove / disable the expander for selected rows. Perhaps by using jQuery.remove.

Headmost answered 27/5, 2010 at 21:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.