DataProvider for non-bean data

Hi,

I’m trying to implement a DataProvider for a DataSet (think Swing like TableModel). For Vaadin 6-7 it was pretty easy using Property / Item / Container philosophy. For Vaadin 10 as I understand Grid must use a DataProvider, but all example and documentation about DataProvider assumes I have some kind of a bean to display - however I only have a dynamic dataset. For example I have a List<MyItem> where MyItem has 3 columns, where you can get the column values with getColumnValue(columnName).
Is there any guidance or does anyone have an idea how to implement a DataProvider without beans, so I can use it for MyItem and show List<MyItem> in a Grid?
Thanks,
Attila

You could provide the keys of your items on the DataProvider (as Strings for example) and then populate the columns with ValueProviders that know how to get the actual data by key.

Here, there is one example in which ValueProviders are used:
https://vaadin.com/components/vaadin-grid/java-examples/filtering

Thanks, it’s working as expected! Here’s my code in case someone find it useful (VaadinItem is essentially an iterator on a DataSet, and dataSet has 3 columns with names col1, col2, col3):

      List<VaadinItem> items = dataSet.toItemList();
      Grid<VaadinItem> grid = new Grid<>();
      grid.setDataProvider(new ListDataProvider<VaadinItem>(items));
      
      grid.addColumn(item -> item.getValue("col1"));
      grid.addColumn(item -> item.getValue("col2"));
      grid.addColumn(item -> item.getValue("col3"));