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
public enum DataTableAlignHow the content of a DataTable column sits in its cells.
- Namespace
- Tesserae
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
| Name | Description |
|---|---|
| DataTable | Initializes a new instance of this class. |
Methods
| Name | Description |
|---|---|
| Column | Adds a column. Call it for every column before adding rows. |
| Row | Adds a row, one component per column. |
| Clear | Removes every row, keeping the columns. |
| Compact | Tightens the padding of the header and the rows. |
| Render | Renders the component's root HTML element. |
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.
| 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. |
public DataTable Compact(bool value = true)Tightens the padding of the header and the rows.