0

i use Grid with DataProvider and lazy loading to load the data into the grid.

How can i get the data from grid after the data was loaded? I mean, i need get a data from grid that already have a data.

i need something like grid.get....

thx.

user1167253
  • 813
  • 1
  • 11
  • 27

2 Answers2

0

I would use grid.getDataCommunicator().fetchFromProvider(..) which returns stream of items method for this, see API spec here: https://demo.vaadin.com/javadoc/com.vaadin/vaadin-core/10.0.2/com/vaadin/flow/data/provider/DataCommunicator.html#fetchFromProvider-int-int-

Tatu Lund
  • 9,949
  • 1
  • 12
  • 26
  • 1
    thanks, bu this method is protected, i can not do this grid.getDataCommunicator().fetchFromProvider(1,1); can you give me a full example please? – user1167253 Aug 09 '18 at 21:52
0

Since Vaadin 17, you can use DataView API to get currently shown item/items in the Grid:

  GridDataView<Person> dataView = grid.getGenericDataView();
  Person item = dataView.getItem(42);
  // or get all shown items
  dataView.getItems().forEach(item -> export(item));

Here is an example how to collect the data for export: https://vaadin.com/docs/latest/flow/binding-data/data-provider/#accessing-currently-shown-items