How to get values of each column on selected rows

Hi

How can I get the values the I selected in a row. I built the grid using Hash Map.

grid.setSelectionMode(SelectionMode.SINGLE);
grid.addSelectionListener(e → {
Set<HashMap<String, String>> selected = e.getAllSelectedItems();
System.out.println(selected.size() + " items selected");

    });

Here are the values that I got from the “selected” variable:

[{CompanyName=Ana Trujillo Emparedados y helados, Address=Avda. de la Constitución 2222, Phone=(5) 555-4729, Region=null, PostalCode=05021, Country=Mexico, CustomerID=ANATR, City=México D.F., Fax=(5) 555-3745, ContactName=Ana Trujillo, ContactTitle=Owner}]

This thread should have the information you are looking for https://vaadin.com/forum/#!/thread/14343801/14343800

When I add those 2 lines I have this issues, please see attachments

Thanks

40208.png
40209.png

I just tried it out

Grid<Object> grid = new Grid<>();
Object selected = ((SingleSelectionModel) grid.getSelectionModel()).getSelectedItem();

seems to work fine, so looking at screenshot 1 it seems like you have not imported the SingleSelectionModel class.
Also, seems that the API has changed since the thread I posted so now the correct method is .getSelectedItem().