0

I need the ability to add a random amount of subgrids to a jqgrid. Basically the subgrid is idential to the parent jqgrid apart from having their column headings hidden. Is there a way where I can define the grid once in say a js file method and have the grid id and data url passed in as a parameter and then append different versions of itself into its subGridRowExpand after its defined. It just seems very laborious to have to define multiple versions of the same jqgrid one inside the other.

Could I do something like

var i = 0;
var maxsubgrids = 5;

function CreateGrid(gridId, dataUrl) {
    $(gridId).grid(
                ...... Grid definition
    subGridRowExpand: function(subgrid_id, row_id) {
        if (subgridcount < maxsubgrids){
            CreateGrid('#subgridId' + i++, subgridDataURL);
        }
    }
    ......... continue with grid definition
}

I know the above isn't correct but just an idea, but I think it would be better if the grid could be just created once in a method and then find a way to insert the subGridRowExpand section afterwards. Is this even possible?

user2096992
  • 43
  • 1
  • 1
  • 5

1 Answers1

0

You should consider to use TreeGrid instead of Subgrids. It's important to understand that subitems of TreeGrid have always the same number of columns like it's parent elements. So I suppose it corresponds to requirements which you have. Of extending of tree node nodeid, parentid and n_level will be automatically added to the list of parameters of the URL (see the documentation).

Oleg
  • 220,925
  • 34
  • 403
  • 798