remove grid row with toolbar button?

title says it all

I have a toolbar above a grid. One of the buttons in the toolbar is Delete Selected Row.

How on earth do i get that button to know which row is currently selected?

You can use

var id = mygrid.getSelectedRowId();

or the next command directly

grid.deleteSelectedRows();