0

I have a two level jqGrid (grid/subgrid) implementation that works very fine. Now I have a requirement that push me to implement a third level subgrid in only some of the second level rows. Is there any way to exclude the opening of the third level if any condition on the row does not permit it?

Thanks very much

EDIT as per @Oleg answer

I have implemented the more complex logic example as in the referenced answer, that is

loadComplete: function() {
    var grid = $("#list");
    var subGridCells = $("td.sgcollapsed",grid[0]);
    $.each(subGridCells,function(i,value){
         [...]
         var rowData = grid.getRowData( ??? );
    });
}

Can I use any field to retrieve the rowData in the each loop?

Lorenzo
  • 29,081
  • 49
  • 125
  • 222

1 Answers1

1

If I understand your question correctly you can do the same like I described in the answer, but do this on the second level of subgrids. To hide "+" icon in some rows you need just execute .unbind("click").html(""); on "td.sgcollapsed" elements of the second level subgrids.

UPDATED: The demo demonstrate how you can get rowid and use getLocalRow (alternatively getRowData) to hide selective subgrid icons ("+" icons). I used the following loadComplete code in the demo:

loadComplete: function () {
    var $grid = $(this);
    $.each($grid.find(">tbody>tr.jqgrow>td.sgcollapsed"), function () {
        var $tdSubgridButton = $(this),
            rowid = $tdSubgridButton.closest("tr.jqgrow").attr("id"),
            rowData = $grid.jqGrid("getLocalRow", rowid);

        if (rowData.amount > 250 ) {
            $tdSubgridButton.unbind("click").html("");
        }
    });
}
Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • thanks for your response. I have implemented in the way you suggest. can I have another quick answer on my question edit? – Lorenzo Oct 09 '13 at 15:38
  • Ok. I have used the `$(value).closest('tr').attr('id')` and then the `grid.getRowdata()` method to retrieve the row data. Thanks again for your help – Lorenzo Oct 09 '13 at 16:55
  • @Lorenzo: I updated my answer, but I see that you found already the solution of the problem. You are welcome! – Oleg Oct 09 '13 at 17:02