mygrid.getSelectedRowId() comes into a dead lock (Bug?)

Hi,
For some reasons, I attach several grids to the same layout cell for several times.

var mylayout;  // pattern 1C
var gridA, gridB;

reload_grid(gridA); // normal
reload_grid(gridB); // normal
reload_grid(gridA); // from here, problem arises, because gridA currently is invisible, but .getSelectedRowId() is executed

function reload_grid(mygrid){
  if(mygrid){
    var sels = mygrid.getSelectedRowId();  // If mygrid is not visible, infinite loops
  }
  mygrid = mylayout.cells("a").attachGrid();
}

I changed the code like below, then the code was executed successfully.

function reload_grid(mygrid){
  if(mygrid && mygrid.isVisible){  // here is the trick
    var sels = mygrid.getSelectedRowId();  // If mygrid is not visible, infinite loops
  }
  mygrid = mylayout.cells("a").attachGrid();
}

Unfortunately it is not available to attach several components to the layout cell using the attach[Component] method.
You need to destruct the previous attached object before attaching the new one using the myGrid.destructor() method.
Also you may try to use the views technique of the layout.
docs.dhtmlx.com/layout__views.html

I did it as you say on toolbar.
Firstly layoutcell.getAttachedToolbar(), then layoutcell.detatchToolbar() or mytoolbar.unload().
But there is no such similar methods for grids on layoutcell. Why, although we can use getAttatchedObject() and detatchObject(), is there any difference?

Please, try to use the destructor() method:
docs.dhtmlx.com/api__dhtmlxgrid_destructor.html