Scroll pagination in Vertical layout

There are messages in the chat layout. Is it possible to do Scroll pagination in Jmix?

Hi,

If your layout is VBox or similar, then I don’t know of any way to implement infinite scrolling.

DataGrid allows you to fetch batches while scrolling. You need to define a special CallbackDataProvider for this. Something like:

    @Subscribe
    public void onInit(final InitEvent event) {
        myEntitiesDataGrid.setItems((CallbackDataProvider.FetchCallback<MyEntity, Void>) query -> {
            // Index of the first item to load
            int offset = query.getOffset();
            // Number of items to load
            int limit = query.getLimit();
            List<MyEntity> loadedEntities = dataManager.load(MyEntity.class)
                    .query("select e from MyEntity e")
                    .firstResult(offset)
                    .maxResults(limit)
                    .list();
            return loadedEntities.stream();
        });
    }