org.dominokit.domino.ui.datatable.plugins.ScrollingPaginationPlugin Maven / Gradle / Ivy
package org.dominokit.domino.ui.datatable.plugins;
import org.dominokit.domino.ui.datatable.DataTable;
import org.dominokit.domino.ui.datatable.events.TablePageChangeEvent;
import org.dominokit.domino.ui.pagination.ScrollingPagination;
/**
* Scrolling Pagination Plugin.
*
* @param
*/
public class ScrollingPaginationPlugin implements DataTablePlugin {
private ScrollingPagination pagination;
public ScrollingPaginationPlugin() {
this(10);
}
public ScrollingPaginationPlugin(int pageSize) {
this(pageSize, 10);
}
public ScrollingPaginationPlugin(int pageSize, int windowSize) {
this.pagination = ScrollingPagination.create(0, pageSize, windowSize);
}
@Override
public void onAfterAddTable(DataTable dataTable) {
dataTable.element().appendChild(pagination.element());
pagination.onPageChanged(pageNumber -> dataTable.fireTableEvent(new TablePageChangeEvent(pageNumber, pagination)));
}
public ScrollingPagination getPagination() {
return pagination;
}
}