Get SubGrid object for a particular row of main Grid

I have a button “Add Row” on main grid row. on click i need to add row in the subgrid of that particular row.

How to get it done?

i come up with the following code

if the subgrid is already opened/expanded by clicking the plus(+) sign the following code works fine without line no.1

Below code is given to open the subgrid manually and add a row

  1. grid.cellById(rowid, 0).open();
  2. var subgrid = grid.cells(rowid, 0).getSubGrid();
  3. var id = subgrid.getRowsNum() + 1;
  4. subgrid.addRow(rowid + “_” + id, []);

I added line no.1 to manually open the subgrid and immediately add row.
but the subgrid opens with headers only and no rows shown.

please help

Unfortunately you need to use the onSubgridLoaded event to control when the subgrid is actually opened and it’s content is inited: