Adding row in a grid as other row's child

I’m adding a row in the grid. But the grid has some rows which are parents and some their children. How to add the row as a first child or the parent? We know the parent id. Here is how I do it now:

myGrid.addRow(myId, myData, null, parentId, "myImage.gif");

Please, try to use addRowBefore() method.
Here is the example:

var child=mygrid.getSubItems(parentId); var arrChild=child.split(","); mygrid.addRowBefore(myId,myData,arrChild[0],"myImage.gif");