Framework: Grid Sort calls sizeInBackEnd and fetchFromBackEnd too often

Created on 3 Apr 2019  路  4Comments  路  Source: vaadin/framework

Vaadin Version: 8.7.1
Browser: Chrome 73.0.3683.86
Web container: Payara Server 4.1.2.181 #badassfish (build 220)

Description: A user-triggered sorting of a simple column calls the dataprovider too often. This creates unnecessary traffic. Possible origin could be the DataCommunicator.

List<Integer> data = new ArrayList<>();
data.add(0);
data.add(1);
data.add(2);

Grid<Integer> grid = new Grid<>();
grid.addSortListener(event -> {
    System.out.println("ON SORT " + event.getComponent().getCaption() + " - " + event.getSortOrder().toString());
});
grid.addColumn(Integer::valueOf).setCaption("ID").setId("id").setSortable(true).setSortProperty("id");

grid.setDataProvider(DataProvider.fromCallbacks(query ->{
    System.out.println("FETCH");
    if(query.getSortOrders().size() > 0) {
        System.out.println("SORT BY " + query.getSortOrders().get(0).getSorted());
    }
    return data.stream();
}, query -> {
    System.out.println("SIZE");
    if(query.getSortOrders().size() > 0) {
        System.out.println("SORT BY " + query.getSortOrders().get(0).getSorted());
    }
    return data.size();
}));

Expectation:

  • Event call
  • sizeInBackEnd (optional)
  • fetchFromBackEnd

Actual behavior:
Log:

SIZE
FETCH
SIZE
SIZE
FETCH - SORT BY id
SIZE
ON SORT null - [com.vaadin.data.provider.GridSortOrder@66ad843d]]
FETCH - SORT BY id

Issue not existent in Vaadin Flow.

Most helpful comment

Same problem, Vaadin version 8.8.0. This makes back-end backed grid unusable.

All 4 comments

Same problem, Vaadin version 8.8.0. This makes back-end backed grid unusable.

Vaadin version 8.8.0, causes grid to be unusable.

I too would like to see this issue fixed as it results in very slow loading of data in the grid component

Please investigate on that issue, we also have the feeling that the grid is very slow when a user-triggered sorting is called

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FSchliephacke picture FSchliephacke  路  4Comments

RobertZenz picture RobertZenz  路  6Comments

Artur- picture Artur-  路  6Comments

sarahfuchs picture sarahfuchs  路  6Comments

ahmadazimi picture ahmadazimi  路  3Comments