Flow Virtitin auto columns disable

Hi, i have added the add on below and created a grid like following code shows. The problem is, that the columns are duplicated. One time it uses them from the record and then my manually added ones. How can i prevent the addon from creating the columns automatically?
Flow Viritin | Vaadin Add-on Directory

public record OrderRecord(String id, String name, String orderdate) {
}


private void createGridPaginated() {
        PagingGrid<OrderRecord> table = new PagingGrid<>(OrderRecord.class);
        table.setPagingDataProvider((page, pageSize) -> {
            int start = (int) (page * pageSize);
            List<QuerySortOrder> sortOrders = new ArrayList<>();
            if (!table.getSortOrder().isEmpty()) {
                GridSortOrder<OrderRecord> sortOrder = table.getSortOrder().get(0);
                String propertyId = sortOrder.getSorted().getKey();
                boolean asc = sortOrder.getDirection() == SortDirection.ASCENDING;
                sortOrders.add(new QuerySortOrder(propertyId, asc ? SortDirection.ASCENDING : SortDirection.DESCENDING));
            }
            return orderDataProvider.fetchFromBackEnd(new Query<>(start, pageSize, sortOrders, null, supplierId)).toList();
        });
        table.addThemeVariants(GridVariant.LUMO_ROW_STRIPES);
        table.addColumn(OrderRecord::ip).setHeader("ID");
        table.addColumn(OrderRecord::name).setHeader("Kundenname");
        table.addColumn(OrderRecord::orderdate).setHeader("Bestelldatum");
        
        table.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
        table.setPageSize(25);

        table.setTotalResults(orderDataProvider.getTotalSize(new Query<>(supplierId)));
        add(table);
    }

This is how it looks like:

This is an expected behaviour of Vaadin Grid (and also of PagingGrid as it’s based on Vaadin Grid): if you pass your bean class into constructor, Grid creates a new Grid with an initial set of columns for each of the bean’s properties.
Just remove the class from constructor and you should get only 3 column with your own headers:

PagingGrid<OrderRecord> table = new PagingGrid<>();
2 Likes

Oh lord, damn easy :smiley: Thank you veryyyyy much!

1 Like