DataTable

Description

DataTable lays out a short scorecard: a header band over rows whose cells are components. Use it for KPI panels and dashboard sections of about a dozen rows, where a cell holds a label, a Sparkline, a TrendBadge or a TargetBar.

Declare every column first with Column, then add one row per record with Row, passing one component per column. A row can carry an accent, any CSS color, drawn on its leading edge to flag its state.

DataTable has no sorting, selection or paging. Use DetailsList when rows come from item objects and need those. Below its minimum width of 640px the table scrolls sideways.

Samples

Columns and rows

Column takes a title, an optional width and an optional alignment (DataTableAlign.Start, Center or End). A column with no width shares the remaining space. Row expects one component per column.

Row accents and compact padding

The first argument of the Row overload with an accent is any CSS color. Compact() tightens the padding of the header and rows.

A KPI scorecard

Each cell is a component, so sizing helpers such as .WS() apply to cells like any other component. The Sparkline cells use .WS() to fill their column.

API reference

enum

DataTableAlign

public enum DataTableAlign

How the content of a DataTable column sits in its cells.

Namespace
Tesserae
class

DataTable

public sealed class DataTable : ComponentBase<DataTable, HTMLElement>

A table whose cells are components: a header band over rows that hold whatever the columns call for - a label, a Sparkline, a TrendBadge, a TargetBar. A row can carry a colored accent on its leading edge, to flag its state at a glance.

Remarks

Unlike DetailsList{T}, which is driven by item objects, the rows here are just the components you hand it; there is no sorting, selection or paging. It is the right size for a dashboard panel of a dozen rows.

Namespace
Tesserae
Inheritance
ComponentBase<DataTable, HTMLElement> → DataTable

Constructors

NameDescription
DataTableInitializes a new instance of this class.
Constructor
DataTable
public DataTable()

Initializes a new instance of this class.

Methods

NameDescription
ColumnAdds a column. Call it for every column before adding rows.
RowAdds a row, one component per column.
ClearRemoves every row, keeping the columns.
CompactTightens the padding of the header and the rows.
RenderRenders the component's root HTML element.
Method
DataTable.Column
public DataTable Column(string title, UnitSize width = null, DataTableAlign align = DataTableAlign.Start)

Adds a column. Call it for every column before adding rows.

Parameters

title
The heading of the column, drawn in small capitals in the header band.
width
The width of the column. Columns without one share what is left equally.
align
How the heading and the cells of the column are aligned.
Method
DataTable.Row
Overload
Row(IComponent[])Adds a row, one component per column.
Row(string, IComponent[])Adds a row with a colored accent on its leading edge, one component per column.
Row(IComponent[])
public DataTable Row(params IComponent[] cells)

Adds a row, one component per column.

Parameters

cells IComponent[]
Row(string, IComponent[])
public DataTable Row(string accent, params IComponent[] cells)

Adds a row with a colored accent on its leading edge, one component per column.

Parameters

accent string
Any CSS color, or a theme variable; null leaves the edge bare.
cells IComponent[]
Method
DataTable.Clear
public DataTable Clear()

Removes every row, keeping the columns.

Method
DataTable.Compact
public DataTable Compact(bool value = true)

Tightens the padding of the header and the rows.

Method
DataTable.Render
public override HTMLElement Render()

Renders the component's root HTML element.

See also