Pagination component can't display correct page tabs

Hi Team:
I refer to the configuration of this document

But my pages always 1 pages. Are there any settings I am missing?

My screen.xml settings:

<data readOnly="true">
        <collection id="taskDc" class="com.company.model.TaskData"/>
</data>

<pagination id="pagination" itemsPerPageOptions="10,20,30" itemsPerPageVisible="true">
        <containerProvider dataContainer="taskDataDc"/>
</pagination>

UiController:
The taskDc has set items in onInit event.

@Install(to = "pagination", subject = "totalCountDelegate")
private Integer paginationTotalCountDelegate() {
        return (int) result.getTotal();    //  ===> There are 41 results
}

Regards.

Hello!

Pagination divides data into pages using loader because it provides setting first and maximum results. Pagination cannot detect “from” and “to” positions if container does not use loader and therefore shows data in one page.
I think in your case, the correct way is to specify loader with delegation. In this delegation, you should consider the first and maximum results while loading data:

<data readOnly="true">
    <collection id="customersDc"
                class="com.company.trpagination.entity.Customer">
        <loader id="customersDl"/>
    </collection>
</data>

...

<pagination id="pagination"
            itemsPerPageOptions="10,20,30"
            itemsPerPageVisible="true">
    <containerProvider dataContainer="customersDc"/>
</pagination>
@Install(to = "customersDl", target = Target.DATA_LOADER)
private List<Customer> customersDlLoadDelegate(LoadContext<Customer> loadContext) {
    int firstResult = loadContext.getQuery().getFirstResult();
    int maxResult = loadContext.getQuery().getMaxResults();
    
    return dataManager.load(Customer.class)
            .query("select e from tr_Customer e")
            .firstResult(firstResult)
            .maxResults(maxResult)
            .list();

    // or using loadContext
    // return dataManager.loadList(loadContext);
}

@Install(to = "pagination", subject = "totalCountDelegate")
private Integer paginationTotalCountDelegate() {
    return Math.toIntExact(dataManager.getCount(new LoadContext<>(customersDc.getEntityMetaClass())));
}
1 Like

Thanks. This is exactly what i want.