To loop through the selected rows of the grid just use the following for statement:
void clicked() { SalesLine salesLine; ; super(); for (salesLine = SalesLine_ds.getFirst(true) ? SalesLine_ds.getFirst(true) : SalesLine_ds.cursor(); salesLine; salesLine = SalesLine_ds.getNext()) { salesLine.doSomethingVerySpecial(:-); } SalesLine_ds.research(true); }