Search code examples
jqueryjqgrid

Hide and disable the expand icon


I have a grid with a grid as subgrid that has a grid as subgrid. Let´s call them grid, subgrid#1 and subgrid#2.

I want to hide and disable the expand icon for the rows of the subgrid#2 depending the value of a column.

The problem is that some rows of the subgrid#1 have the same id of the rows of the subgrid. So, in some cases, instead of hiding and disabling the click of the rows of the subgrid#2, the row of the subgrid#1 is affected.

This is the code that i'm using to hide and disable the click:

$(this).find("td.ui-sgcollapsed>a").hide();
$(this).find("td.ui-sgcollapsed").unbind('click').html('');

Solution

  • Please write always, which version you use (can use) and from which fork of jqGrid (free jqGrid, commercial Guriddo jqGrid JS or an old jqGrid in version <=4.7).

    Free jqGrid has since a long time the feature, which you can use. One can define hasSubgrid callback inside of subGridOptions, which inform jqGrid whether to create subgrid icon in the row. The callback hasSubgrid get the data of row as parameter. So it's very easy to implement your requirement. See the answer or another one with the demo for more details.