Skip to content

1.2. Creating Data Models

Evren Coskun edited this page Aug 10, 2020 · 2 revisions

TableView uses three Data Models to store the contents of the Row, Column and data cells, these models can be as simple as a Java primitive Object like String or a POJO Class with getters (and setters).

Basic generic POJO classes

public class Cell {
  @Nullable
  private Object mData;

  public Cell(@Nullable Object data) {
    this.mData = data;
  }

  @Nullable
    public Object getData() {
        return mData;
    }
}
public class ColumnHeader extends Cell {
    public ColumnHeader(@Nullable Object data) {
        super(data);
    }
}
public class RowHeader extends Cell {
    public RowHeader(@Nullable Object data) {
        super(data);
    }
}

To enable Sorting and Filtering they should implement the ISortableModel and or IFilterableModel interfaces (See the Sorting and Filtering documentation pages for more details).