Paging with custom data loader

Hi all,

I have a custom data loader that is gathering several entities from different tables, and converts them to a generic entity. That way I can show different entities in one table.
The way the data loader is set up:
@Install(to = “myCustomDl”, target = Target.DATA_LOADER)

Now I am trying to get pagination to work, I added a filter component and I can read the desired maxRow value the user sets in the filter and somehow I will find a way to gather only that amount of entities. But what is missing in the UI is the ability to go to the next page. Only the total count of table entries is displayed.

I was thinking that I maybe need to provide CUBA with some extra information like “getNextEntities()” or even implement a new CollectionLoader. But I only found an old example from 2016 so I don’t know if there are better methods in CUBA 7.2 (GitHub - aleksey-stukalov/custom-datasource: This example illustrates how to create and use custom collection datasource in the CUBA Platform).

Thanks for any pointers!


The navigation buttons in the pagination will be shown if the first page is full. In your load delegate, the context contains information about firstResult and maxResult. Using these properties you can try to implement custom pagination:

@Install(to = "myCustomDl", target = Target.DATA_LOADER)
private List<Order> ordersDlLoadDelegate(LoadContext<Order> loadContext) {
    int firstResult = loadContext.getQuery().getFirstResult();
    int maxResults = loadContext.getQuery().getMaxResults();
    // perform loading

Thanks, Roman, that is helping me a lot!


LoadContext passed to the load delegate contains the LoadContext.Query object that contains info needed for pagination:

@Install(to = "usersDl", target = Target.DATA_LOADER)
private List<User> usersDlLoadDelegate(LoadContext<User> loadContext) {
    LoadContext.Query query = loadContext.getQuery();
    int firstResult = query.getFirstResult();
    int maxResults = query.getMaxResults();



1 Like

Thanks Gleb! :slight_smile: