Class GridBuilder<D>

java.lang.Object
org.ujorm.tools.web.table.GridBuilder<D>
Direct Known Subclasses:
GridBuilderOld

public class GridBuilder<D> extends Object
Build a content of a HTML page for a sortable data grid.
Author:
Pavel Ponec
  • Field Details

  • Constructor Details

    • GridBuilder

      public GridBuilder(@NotNull @NotNull CharSequence title)
    • GridBuilder

      public GridBuilder(@NotNull @NotNull HtmlConfig config)
    • GridBuilder

      public GridBuilder(@NotNull @NotNull GridBuilderConfig config)
  • Method Details

    • add

      @NotNull public <V> @NotNull GridBuilder<D> add(Function<D,V> column)
    • add

      @NotNull public <V> @NotNull GridBuilder<D> add(Function<D,V> column, CharSequence title)
    • add

      @NotNull public <V> @NotNull GridBuilder<D> add(Function<D,V> column, Injector title)
    • add

      @NotNull public <V> @NotNull GridBuilder<D> add(Function<D,V> column, CharSequence title, @Nullable @Nullable HttpParameter param)
    • add

      @NotNull public <V> @NotNull GridBuilder<D> add(Function<D,V> column, Injector title, @Nullable @Nullable HttpParameter param)
    • addColumn

      @NotNull public @NotNull GridBuilder<D> addColumn(@NotNull @NotNull Column<D> column, @NotNull @NotNull CharSequence title)
    • addColumn

      @NotNull public @NotNull GridBuilder<D> addColumn(@NotNull @NotNull Column<D> column, @NotNull @NotNull Injector title)
    • addOrder

      @NotNull public @NotNull GridBuilder<D> addOrder(@NotNull @NotNull CharSequence title)
      Add new column for a row counting
    • addInternal

      @NotNull protected <V> @NotNull GridBuilder<D> addInternal(@NotNull @NotNull Function<D,V> column, @NotNull @NotNull CharSequence title, @Nullable @Nullable HttpParameter param)
    • getColumn

      public ColumnModel<D,?> getColumn(int index)
      Get column model by index
    • getColumnSize

      public int getColumnSize()
      Returns a count of columns
    • sortable

      @NotNull public <V> @NotNull GridBuilder<D> sortable()
      Add a sortable indicator to the last column model
      Returns:
    • sortable

      @NotNull public <V> @NotNull GridBuilder<D> sortable(@Nullable @org.jetbrains.annotations.Nullable boolean ascending)
      Add a sortable indicator to the last column model
      Parameters:
      ascending - Ascending or descending direction of the sort
      Returns:
    • sortable

      @NotNull public <V> @NotNull GridBuilder<D> sortable(@NotNull @NotNull Direction direction)
      Add a sortable indicator to the last column model
      Parameters:
      direction - The null value shows an unused sorting action.
      Returns:
    • getSortedColumn

      @NotNull public @NotNull ColumnModel<D,?> getSortedColumn()
      Get sorted column or a stub of the sorted column was not found
    • build

      public void build(@NotNull @NotNull ApiElement parent, @NotNull @NotNull Function<GridBuilder<D>,Stream<D>> resource)
      Build the HTML page including a table
    • build

      public void build(@NotNull @NotNull ApiElement parent, @NotNull @NotNull ColumnModel sortedColumn, @NotNull @NotNull Function<GridBuilder<D>,Stream<D>> resource)
      Build the HTML page including a table
    • setSort

      protected void setSort(@NotNull @NotNull ColumnModel sort)
      Mark a column as sorted
    • printTable

      protected void printTable(@NotNull @NotNull Element parent, @NotNull @NotNull Function<GridBuilder<D>,Stream<D>> resource)
      Print table
      Parameters:
      parent - If a name of the element is a "table" or an empty text then do not create new table element.
      resource - Data source
    • isSortable

      public final boolean isSortable()
      Returns the true in case the table is sortable. NOTE: Calculated result is cached, call the method on a final model only!
    • isSortableCalculated

      public boolean isSortableCalculated()
      Calculate if the table has an sortable column
    • getColumns

      public Stream<ColumnModel<D,?>> getColumns()
      Returns all table columns in a stream