Get the next row of the selected item on grid

Is there a way that I can get the next row of the selected item on grid on vaadin 8.1.1?

No, for performance reasons DataProviders do not require (nor do the standard ones implement) many of the methods that Vaadin 7 containers did. You cannot ask the DataProvider for the next or previous row nor can you retrieve the index. If you require that functionality, you have to write a custom DataProvider that implements those features (something along an IndexedDataProvider similar to IndexedContainer).

I’m trying to make shift select for grid without using checkbox on its left. It is easy for initial rendered grid since I can get the items from the dataprovider. However, if the grid is sorted, then I’m not able to get the items since the order of items in dataprovider still remains in initial order.

Is there any way that I can implement the shift-select?

gr.addItemClickListener(l -> {
 if (l.getMouseEventDetails().isShiftKey()) {
  if (gr.getSelectedItems().contains(l.getItem())) {
  } else {;

if (event.getMouseEventDetails().isCtrlKey()) {
this.lastSelect = receiptdata;;
} else if (event.getMouseEventDetails().isShiftKey()) {
if (this.lastSelect == null) {
this.lastSelect = receiptdata;;
} else {
// Need to implement to select from the last selected item to the current selected item.
} else {
this.lastSelect = receiptdata;;

Yours shift-select seems only select one item. I want to select from the last selected item to the current selected item just like the way I can select files from windows file explorer.

Ah, I get it now, you want to implement a range select.

In this case, as I said before - you need a custom DataProvider that will return you information about all items that are between two given items. It’s actually much less trivial than you made it to be - since sorting can separate clusters of previously selected elements, you have to first search for the closest selected element after the sort was performed, then return a list of all elements between that one and the selected one. Seems like you need a DataProvider backed by some data structure that can handle ranges well - possibly a TreeSet?

Do you think it is possible to implement where the dataprovide is a list of hashmap?

Since the # of columns can vary, I used hashmap.

BTW thank you for your fast reply.

Yes, but you’ll have to extend the DataProvider with a custom one that supports things such as

Are you able to provide me some hints/resources how to resolve this problem??

I’m attaching my current implementation for grid :
// List of header labels in order
private List header;
// key, value : key, actual value that comes on grid header
private LinkedHashMap<String, String> headerMap;
// Actual data holding dataprovider
private List data;

public void renderData(List data){
for (String caption : this.header) {
Grid.Column<Receiptdata, String> column = this.addColumn(
(ValueProvider<Receiptdata, String>) dataHashMap → dataHashMap.get(this.headerMap.get(caption)))




public class Receiptdata extends HashMap<String, String>{
// key, value : key is key value from headerMap, value is actual data to render on grid body