// state.setRowIndex(ScrollableDataTableUtils.getClientRowIndex(grid));
Object savedKey = table.getRowKey();
final TableHolder holder = new TableHolder(table);
final Selection gridSelection = table.getSelection() == null ? new SimpleSelection()
: table.getSelection();
final ClientSelection clientSelection = new ClientSelection();
table.walk(context, new DataVisitor() {
public void process(FacesContext context, Object rowKey,
Object argument) throws IOException {
// TableHolder holder = (TableHolder) argument;
if (gridSelection.isSelected(rowKey)) {
int i = holder.getRowCounter();
clientSelection.addIndex(i);
}