Class DataTable<T>

java.lang.Object
io.mindspice.simplypages.core.HtmlTag
io.mindspice.simplypages.components.display.DataTable<T>
All Implemented Interfaces:
Component

public class DataTable<T> extends HtmlTag
Object-backed table renderer with column extractors.

Mutable and not thread-safe. Columns and rows are accumulated on this instance. Mutate within a request-scoped flow. For reuse, stop mutating and render as a stable structure with per-request slot/context values.

  • Constructor Details

    • DataTable

      public DataTable()
      Creates a data-table wrapper container.
  • Method Details

    • create

      public static <T> DataTable<T> create(Class<T> dataClass)
      Creates a data table.
      Type Parameters:
      T - row object type
      Parameters:
      dataClass - ignored type token retained for fluent API ergonomics
      Returns:
      new data table
    • addColumn

      public DataTable<T> addColumn(String header, Function<T,String> extractor)
      Adds a column with header and value extractor.
      Parameters:
      header - column header text
      extractor - maps row object to cell text
      Returns:
      this table
    • addColumn

      public DataTable<T> addColumn(String header, Function<T,String> extractor, String cssClass)
      Adds a column with optional CSS class.
      Parameters:
      header - column header text
      extractor - maps row object to cell text
      cssClass - optional class applied to header and cell
      Returns:
      this table
    • withData

      public DataTable<T> withData(List<T> data)
      Appends all provided rows.
      Parameters:
      data - rows to append
      Returns:
      this table
    • addRow

      public DataTable<T> addRow(T item)
      Appends one row object.
      Parameters:
      item - row object
      Returns:
      this table
    • striped

      public DataTable<T> striped()
      Enables striped table class.
      Returns:
      this table
    • bordered

      public DataTable<T> bordered()
      Enables bordered table class.
      Returns:
      this table
    • hoverable

      public DataTable<T> hoverable()
      Enables hover table class.
      Returns:
      this table
    • sortable

      public DataTable<T> sortable()
      Enables sortable class markers.

      This method adds CSS hooks only; client-side sorting behavior is application-defined.

      Returns:
      this table
    • getChildrenStream

      protected Stream<Component> getChildrenStream()
      Materializes a table child and returns it with any additional inherited children.
      Overrides:
      getChildrenStream in class HtmlTag
      Returns:
      children stream