is there a way to expand a subtreegrid using a function
If you mean sub-grids it can be done as
grid.cells(i,j).open();
where i,j - coordinates ( row id and column index ) of related sub_row_grid cell.
In case of treeGrid, the same can be done as
grid.openItem(rowId);