How to add new row beneath the selected row?

Hello all,

When a new row is added, it is added at the bottom of the grid which is the default behavior.
Can somebody help me, how to add a new row just below the selected row?

You can get the id of a selected row:

var selectedId=mygrid.getSelectedRowId();

Than you can find the index of this row:

var rowIndex=mygrid.getRowIndex("selectedId");

And than you can create a new row and place it after the selected one: