Search in sources :

Example 1 with SimplePaginationPlugin

use of org.dominokit.domino.ui.datatable.plugins.SimplePaginationPlugin in project domino-ui-demo by DominoKit.

the class DataTableViewImpl method simplePagination.

@SampleMethod
private void simplePagination() {
    // page size
    SimplePaginationPlugin<Contact> simplePaginationPlugin = new SimplePaginationPlugin<>(10);
    TableConfig<Contact> tableConfig = new TableConfig<>();
    tableConfig.addColumn(ColumnConfig.<Contact>create("id", "#").textAlign("right").asHeader().sortable().setCellRenderer(cell -> TextNode.of(cell.getTableRow().getRecord().getIndex() + 1 + ""))).addColumn(ColumnConfig.<Contact>create("status", "Status").textAlign("center").setCellRenderer(cell -> {
        if (cell.getTableRow().getRecord().isActive()) {
            return Style.of(Icons.ALL.check_circle()).setColor(Color.GREEN_DARKEN_3.getHex()).element();
        } else {
            return Style.of(Icons.ALL.highlight_off()).setColor(Color.RED_DARKEN_3.getHex()).element();
        }
    })).addColumn(ColumnConfig.<Contact>create("firstName", "First name").sortable().setCellRenderer(cell -> TextNode.of(cell.getTableRow().getRecord().getName()))).addColumn(ColumnConfig.<Contact>create("gender", "Gender").setCellRenderer(cell -> ContactUiUtils.getGenderElement(cell.getRecord())).textAlign("center")).addColumn(ColumnConfig.<Contact>create("eyeColor", "Eye color").setCellRenderer(cell -> ContactUiUtils.getEyeColorElement(cell.getRecord())).textAlign("center")).addColumn(ColumnConfig.<Contact>create("balance", "Balance").sortable().setCellRenderer(cellInfo -> ContactUiUtils.getBalanceElement(cellInfo.getRecord()))).addColumn(ColumnConfig.<Contact>create("email", "Email").setCellRenderer(cell -> TextNode.of(cell.getTableRow().getRecord().getEmail()))).addColumn(ColumnConfig.<Contact>create("phone", "Phone").setCellRenderer(cell -> TextNode.of(cell.getTableRow().getRecord().getPhone()))).addColumn(ColumnConfig.<Contact>create("badges", "Badges").setCellRenderer(cell -> {
        if (cell.getTableRow().getRecord().getAge() < 35) {
            return Badge.create("Young").setBackground(ColorScheme.GREEN.color()).element();
        }
        return TextNode.of("");
    }));
    tableConfig.addPlugin(new SortPlugin<>()).addPlugin(new HeaderBarPlugin<Contact>("Demo table", "this a sample table with all features").addActionElement(new HeaderBarPlugin.ClearSearch<>()).addActionElement(new HeaderBarPlugin.SearchTableAction<>())).addPlugin(simplePaginationPlugin);
    LocalListDataStore<Contact> localListDataStore = new LocalListDataStore<>();
    localListDataStore.setRecordsSorter(new ContactSorter());
    localListDataStore.setSearchFilter(new ContactSearchFilter());
    localListDataStore.setPagination(simplePaginationPlugin.getSimplePagination());
    DataTable<Contact> table = new DataTable<>(tableConfig, localListDataStore);
    element.appendChild(Card.create("SIMPLE PAGINATION", "Simple pagination plugin allows the table to fire pagination events helpful for the datasource").setCollapsible().appendChild(new TableStyleActions(table)).appendChild(table).element());
    contactListParseHandlers.add(contacts -> {
        localListDataStore.setData(subList(contacts, 0, 100));
        table.load();
    });
}
Also used : SimplePaginationPlugin(org.dominokit.domino.ui.datatable.plugins.SimplePaginationPlugin) SampleClass(org.dominokit.domino.SampleClass) JsonResource(org.dominokit.domino.datatable.client.views.JsonResource) SampleMethod(org.dominokit.domino.SampleMethod) SelectionPlugin(org.dominokit.domino.ui.datatable.plugins.SelectionPlugin) UiView(org.dominokit.domino.api.client.annotations.UiView) Date(java.util.Date) CodeCard(org.dominokit.domino.componentcase.client.ui.views.CodeCard) DoubleBox(org.dominokit.domino.ui.forms.DoubleBox) Style(org.dominokit.domino.ui.style.Style) TreeGridSample(org.dominokit.domino.datatable.client.views.model.TreeGridSample) Paragraph(org.dominokit.domino.ui.Typography.Paragraph) Random(java.util.Random) HTMLTableCellElement(elemental2.dom.HTMLTableCellElement) ContactSearchFilter(org.dominokit.domino.datatable.client.views.model.ContactSearchFilter) Notification(org.dominokit.domino.ui.notifications.Notification) Icon(org.dominokit.domino.ui.icons.Icon) EmailBox(org.dominokit.domino.ui.forms.EmailBox) HTMLElement(elemental2.dom.HTMLElement) TextHeaderFilter(org.dominokit.domino.ui.datatable.plugins.filter.header.TextHeaderFilter) HeaderBarPlugin(org.dominokit.domino.ui.datatable.plugins.HeaderBarPlugin) SimplePaginationPlugin(org.dominokit.domino.ui.datatable.plugins.SimplePaginationPlugin) Card(org.dominokit.domino.ui.cards.Card) ResourceException(com.google.gwt.resources.client.ResourceException) TableConfig(org.dominokit.domino.ui.datatable.TableConfig) TextResource(com.google.gwt.resources.client.TextResource) BaseDemoView(org.dominokit.domino.componentcase.client.ui.views.BaseDemoView) DominoElement(org.dominokit.domino.ui.utils.DominoElement) RecordDetailsPlugin(org.dominokit.domino.ui.datatable.plugins.RecordDetailsPlugin) BooleanHeaderFilter(org.dominokit.domino.ui.datatable.plugins.filter.header.BooleanHeaderFilter) Collectors(java.util.stream.Collectors) SortPlugin(org.dominokit.domino.ui.datatable.plugins.SortPlugin) List(java.util.List) Select(org.dominokit.domino.ui.forms.Select) Color(org.dominokit.domino.ui.style.Color) Unit.px(org.dominokit.domino.ui.style.Unit.px) ColumnHeaderFilterPlugin(org.dominokit.domino.ui.datatable.plugins.ColumnHeaderFilterPlugin) ScrollingPaginationPlugin(org.dominokit.domino.ui.datatable.plugins.ScrollingPaginationPlugin) Optional(java.util.Optional) GroupingPlugin(org.dominokit.domino.ui.datatable.plugins.GroupingPlugin) CheckBox(org.dominokit.domino.ui.forms.CheckBox) ContactList(org.dominokit.domino.datatable.client.views.model.ContactList) EyeColor(org.dominokit.domino.datatable.client.views.model.EyeColor) DatatableProxy(org.dominokit.domino.datatable.client.presenters.DatatableProxy) Icons(org.dominokit.domino.ui.icons.Icons) ColumnConfig(org.dominokit.domino.ui.datatable.ColumnConfig) RowCell(org.dominokit.domino.ui.datatable.RowCell) TreeGridPlugin(org.dominokit.domino.ui.datatable.plugins.TreeGridPlugin) Elements.a(org.jboss.elemento.Elements.a) Elements.td(org.jboss.elemento.Elements.td) Badge(org.dominokit.domino.ui.badges.Badge) LocalListDataStore(org.dominokit.domino.ui.datatable.store.LocalListDataStore) TopPanelPlugin(org.dominokit.domino.ui.datatable.plugins.TopPanelPlugin) DoubleHeaderFilter(org.dominokit.domino.ui.datatable.plugins.filter.header.DoubleHeaderFilter) DatatableView(org.dominokit.domino.datatable.client.views.DatatableView) AdvancedPaginationPlugin(org.dominokit.domino.ui.datatable.plugins.AdvancedPaginationPlugin) TableEvent(org.dominokit.domino.ui.datatable.events.TableEvent) DataTable(org.dominokit.domino.ui.datatable.DataTable) ArrayList(java.util.ArrayList) BlockHeader(org.dominokit.domino.ui.header.BlockHeader) LinkToSourceCode(org.dominokit.domino.componentcase.client.ui.views.LinkToSourceCode) Elements.div(org.jboss.elemento.Elements.div) SelectHeaderFilter(org.dominokit.domino.ui.datatable.plugins.filter.header.SelectHeaderFilter) Gender(org.dominokit.domino.datatable.client.views.model.Gender) BodyScrollPlugin(org.dominokit.domino.ui.datatable.plugins.BodyScrollPlugin) SelectOption(org.dominokit.domino.ui.forms.SelectOption) TextNode(org.dominokit.domino.ui.utils.TextNode) TextBox(org.dominokit.domino.ui.forms.TextBox) ContactSorter(org.dominokit.domino.datatable.client.views.model.ContactSorter) CellRenderer(org.dominokit.domino.ui.datatable.CellRenderer) LocalListScrollingDataSource(org.dominokit.domino.ui.datatable.store.LocalListScrollingDataSource) ResourceCallback(com.google.gwt.resources.client.ResourceCallback) ColorScheme(org.dominokit.domino.ui.style.ColorScheme) EnumHeaderFilter(org.dominokit.domino.ui.datatable.plugins.filter.header.EnumHeaderFilter) Contact(org.dominokit.domino.datatable.client.views.model.Contact) DomGlobal(elemental2.dom.DomGlobal) TableDataUpdatedEvent(org.dominokit.domino.ui.datatable.events.TableDataUpdatedEvent) HTMLDivElement(elemental2.dom.HTMLDivElement) FieldStyle(org.dominokit.domino.ui.forms.FieldStyle) TelephoneBox(org.dominokit.domino.ui.forms.TelephoneBox) Comparator(java.util.Comparator) RowMarkerPlugin(org.dominokit.domino.ui.datatable.plugins.RowMarkerPlugin) Collections(java.util.Collections) ContactSearchFilter(org.dominokit.domino.datatable.client.views.model.ContactSearchFilter) HeaderBarPlugin(org.dominokit.domino.ui.datatable.plugins.HeaderBarPlugin) DataTable(org.dominokit.domino.ui.datatable.DataTable) ContactSorter(org.dominokit.domino.datatable.client.views.model.ContactSorter) Contact(org.dominokit.domino.datatable.client.views.model.Contact) LocalListDataStore(org.dominokit.domino.ui.datatable.store.LocalListDataStore) TableConfig(org.dominokit.domino.ui.datatable.TableConfig) SampleMethod(org.dominokit.domino.SampleMethod)

Aggregations

ResourceCallback (com.google.gwt.resources.client.ResourceCallback)1 ResourceException (com.google.gwt.resources.client.ResourceException)1 TextResource (com.google.gwt.resources.client.TextResource)1 DomGlobal (elemental2.dom.DomGlobal)1 HTMLDivElement (elemental2.dom.HTMLDivElement)1 HTMLElement (elemental2.dom.HTMLElement)1 HTMLTableCellElement (elemental2.dom.HTMLTableCellElement)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 Date (java.util.Date)1 List (java.util.List)1 Optional (java.util.Optional)1 Random (java.util.Random)1 Collectors (java.util.stream.Collectors)1 SampleClass (org.dominokit.domino.SampleClass)1 SampleMethod (org.dominokit.domino.SampleMethod)1 UiView (org.dominokit.domino.api.client.annotations.UiView)1 BaseDemoView (org.dominokit.domino.componentcase.client.ui.views.BaseDemoView)1 CodeCard (org.dominokit.domino.componentcase.client.ui.views.CodeCard)1