org.dominokit.domino.ui.datatable.plugins.AdvancedPaginationPlugin 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.AdvancedPagination;
/**
* Advanced Pagination Plugin.
*
* @param
*/
public class AdvancedPaginationPlugin implements DataTablePlugin {
private AdvancedPagination pagination;
public AdvancedPaginationPlugin() {
this(10);
}
public AdvancedPaginationPlugin(int pageSize) {
this.pagination = AdvancedPagination.create(0, pageSize);
}
@Override
public void onAfterAddTable(DataTable dataTable) {
dataTable.element().appendChild(pagination.element());
pagination.onPageChanged(pageNumber -> dataTable.fireTableEvent(new TablePageChangeEvent(pageNumber, pagination)));
}
public AdvancedPagination getPagination() {
return pagination;
}
}