Class CliTable
App-facing convenience API for CliTable: theme-driven defaults plus terse
header and record construction. These methods sit on top of the existing Header,
Records, FrameConfig, and Orientation members and do
not introduce a separate rendering or theming path — table looks come from ITheme.
public class CliTable : CliRenderableComponent, ICliRenderable
- Inheritance
-
CliTable
- Implements
- Inherited Members
Remarks
A table materializes to a CliGrid through ToGrid(). Vertical
orientation renders header elements as columns and records as rows; horizontal orientation
renders header elements as row labels and records as value columns. The instance is mutable and
the fluent helpers return this table for chaining.
Properties
AlternateRecordsEnabled
Enables use of DataAltStyle for alternate records during rendering.
Default is
false.public bool AlternateRecordsEnabled { get; set; }
Property Value
DataAltStyle
Alternate record style used when AlternateRecordsEnabled is enabled.
public CliCellStyle? DataAltStyle { get; set; }
Property Value
DataStyle
Default style for each record axis. In vertical orientation this applies to data rows; in
horizontal orientation this applies to value columns.
public CliCellStyle? DataStyle { get; set; }
Property Value
FrameConfig
Frame and separator configuration used when the table is converted to a grid.
public CliTableFrameConfig FrameConfig { get; set; }
Property Value
Header
Gets the table header definition.
public CliTableHeader Header { get; init; }
Property Value
Orientation
Gets or sets the orientation of the table (vertical or horizontal).
Default is Vertical.
public CliTableOrientation Orientation { get; set; }
Property Value
Records
Gets or sets the list of record objects to be rendered in the table.
public IList<IList<object?>> Records { get; set; }
Property Value
Title
Optional table title rendered above the table body.
public CliTableTitle? Title { get; set; }
Property Value
TitleStyle
The current default title style, set by ApplyStyle(CliTableStyle) / ApplyPreset(CliTableStylePreset, ITheme?, CliTableOrientation?)
from the applied TitleStyle. AddTitle(string) clones
this when creating the Title, so callers do not pass a style explicitly.
public CliCellStyle? TitleStyle { get; set; }
Property Value
TreatDbNullAsNull
public bool? TreatDbNullAsNull { get; set; }
Property Value
- bool?
Methods
AddHeader(params string[])
Adds one header element per caption, in order. Captions are plain strings — pass
localized text such as
settings.T("Name") or string literals. Markup in a caption
is rendered as markup, matching the single-string element constructor.public CliTable AddHeader(params string[] cells)
Parameters
cellsstring[]- Header captions, one per field.
Returns
- CliTable
- This table, for fluent chaining.
AddRecord(params object?[])
Adds a single data record from simple values such as string, enum,
bool, int, or
null. Each value is rendered through
normal string conversion; null renders safely (empty, or the field's null display
value). Records are orientation-neutral — vertical rendering shows them as rows, horizontal
rendering shows them as value columns. The value count must match
Elements when the table is rendered.public CliTable AddRecord(params object?[] values)
Parameters
valuesobject[]- The record's values, one per field.
Returns
- CliTable
- This table, for fluent chaining.
AddTitle(object, CliFormattingMode, CliFormatter?)
Sets the table Title from arbitrary content with an explicit
CliFormattingMode (and optional CliFormatter), using the table's
current TitleStyle. The current title style is cloned so the table owns its copy;
the requested formatting mode and formatter override the clone. Does not alter the
header/body/frame styles, the frame config, or the applied style selection.
public CliTable AddTitle(object title, CliFormattingMode formattingMode, CliFormatter? formatter = null)
Parameters
titleobject- The title content. Must not be
null. formattingModeCliFormattingMode- How the content is formatted.
formatterCliFormatter- An optional formatter; when
nullthe current style's formatter is kept.
Returns
- CliTable
- This table, for fluent chaining.
AddTitle(string)
Sets the table Title from preformatted, markup-aware content, using the table's
current TitleStyle (set by the last ApplyStyle(CliTableStyle)/ApplyPreset(CliTableStylePreset, ITheme?, CliTableOrientation?)).
Titles are app-provided and sit outside the table surface — built-in presets pin the title
background to the theme's base surface while varying only the title foreground. This does not
alter the header/body/frame styles, the frame config, or the applied style selection.
public CliTable AddTitle(string title)
Parameters
titlestring- The title text; TigerCli markup is honoured. Must not be
null.
Returns
- CliTable
- This table, for fluent chaining.
ApplyPreset(CliTableStylePreset, ITheme?, CliTableOrientation?)
Applies a built-in table style preset to this table. Resolves the preset's recipe through
theme (the CurrentTheme when null) and
applies it as defaults via ApplyStyle(CliTableStyle) — the table can still be customized
afterwards. When orientation is omitted the preset's default orientation
is used (orientation-locked presets clamp to their own).public CliTable ApplyPreset(CliTableStylePreset preset, ITheme? theme = null, CliTableOrientation? orientation = null)
Parameters
presetCliTableStylePreset- The built-in preset (city or alias) to apply.
themeITheme- The theme that resolves the preset; defaults to the current theme.
orientationCliTableOrientation?- Desired orientation as part of preset application; defaults to vertical.
Returns
- CliTable
- This table, for fluent chaining.
ApplyStyle(CliTableStyle)
Applies resolved table defaults to this table. Copies the style so reusing a
CliTableStyle across tables is safe. Sets defaults only; the table can be
modified afterwards. Titles are app-provided, so TitleStyle
is exposed for callers but not forced onto an existing Title.
public CliTable ApplyStyle(CliTableStyle style)
Parameters
styleCliTableStyle- The resolved table style to apply.
Returns
- CliTable
- This table, for fluent chaining.
SetOrientation(CliTableOrientation)
Sets the table orientation. Orientation-locked styles clamp to their supported orientation.
public CliTable SetOrientation(CliTableOrientation orientation)
Parameters
orientationCliTableOrientation- The desired orientation.
Returns
- CliTable
- This table, for fluent chaining.
ToGrid()
Materializes this table as a CliGrid for rendering.
public override CliGrid ToGrid()
Returns
- CliGrid
- A grid containing the title, frame, header elements, and records.
Exceptions
- TigerCliException
- The table has no header elements, or a record has a different value count than the header element count.
UseAlternateRecords(bool)
Enables or disables alternate-record rendering using the existing DataAltStyle.
public CliTable UseAlternateRecords(bool enabled = true)
Parameters
enabledbool- Whether alternate records should be rendered with DataAltStyle.
Returns
- CliTable
- This table, for fluent chaining.