All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.dominokit.domino.ui.datatable.events.SimplePaginationPlugin Maven / Gradle / Ivy

There is a newer version: 1.0.139
Show newest version
package org.dominokit.domino.ui.datatable.events;

import org.dominokit.domino.ui.datatable.DataTable;
import org.dominokit.domino.ui.datatable.plugins.DataTablePlugin;
import org.dominokit.domino.ui.pagination.SimplePagination;

public class SimplePaginationPlugin implements DataTablePlugin {

    private SimplePagination simplePagination;

    private final int pageSize;

    public SimplePaginationPlugin() {
        this(10);
    }

    public SimplePaginationPlugin(int pageSize) {
        this.pageSize = pageSize;
        this.simplePagination = SimplePagination.create(0, pageSize)
                .markActivePage()
                .gotoPage(1);
    }

    @Override
    public void onAfterAddTable(DataTable dataTable) {
        dataTable.element()
                .appendChild(simplePagination.element());

        simplePagination.onPageChanged(pageNumber -> dataTable.fireTableEvent(new TablePageChangeEvent(pageNumber, simplePagination)));
    }

    public SimplePagination getSimplePagination() {
        return simplePagination;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy