Accessing a SubGrid

I am going thru the rows of a grid and when I come to a subgrid - I want to access it and go thru its rows - here is some code I am trying:

var rowids = (grid.getAllRowIds()).split(’,’);

for (var inx = 0; inx < rowids.length; inx++) {

if(/^Changes:(\d+)$/.test(rowids[inx])) {

var cell = grid.cellById(rowids[inx], 0);
alert("CELL = " + cell);

if(cell) cell.open();
                                              
var sg;
 if(cell) sg = cell.getSubGrid()
 alert("SUBGRID = " + sg);         

}

I got getSubGrid() from:
docs.dhtmlx.com/doku.php?id=dhtm … me_excells

This code comes back with a valid cell object - and the cell.open() call expands the subgrid - BUT the sub grid is undefined.

Any ideas?

Thanks in advance…

Sub grid object is defined only after you opened sub grid row at list once.