Table
ConsoleMonster.Widgets
A table that negotiates its width instead of overflowing or silently dropping data: columns shrink to their minimum (wrapping, truncating at the end or in the middle, per column), then hide by ascending TableColumn.Priority with a footer that names them (+3 columns (Owner, Site, Notes)); the key column never hides. Below Table.CardsBelow cells the rows become record cards, and a single row becomes a record view. Rows can be grouped with subtotals, followed by a totals row, and limited to the top N with a Showing 50 of 1,234 footer. Raw values are formatted by the column presenters. Table.For makes a Table<T> whose columns are read from typed items.
Inheritance
- object
- Table
Derived Types
Constructors
public Table() #Methods
public void ClearRows() #Removes every row (columns, options and remembered column widths stay), so the table can be refilled.
public Table Column(string header, HorizontalAlignment? alignment = null) #Adds a column.
Parameters
- header string
- The header (markup).
- alignment ConsoleMonster.Layout.HorizontalAlignment? = null
- Alignment, or null for automatic.
public Table Column(TableColumn column) #Adds a column definition.
Parameters
- column ConsoleMonster.Widgets.TableColumn
- The column.
public bool DisplaysColumn(string name, int width, RenderContext context) #Whether a named column is displayed at the destination width, including below-row detail or record layouts.
Parameters
- name string
- The column key or unstyled header.
- width int
- Available cells.
- context ConsoleMonster.Canvas.RenderContext
- The destination render context.
Returns
bool False when the column is absent or hidden.public static Table<T?> For<T>(IEnumerable<T?> items) #Makes a table from typed items. Add columns with Table<T>.Column (the header comes from the expression: s => s.Name is "Name"); without any, every public property of T is a column. Rows are read from the items when the table is laid out.
Type Parameters
- T
- The item type.
Parameters
- items System.Collections.Generic.IEnumerable<T?>
- The items.
public Table Group(string title) #Starts a group: rows added after this belong to it until the next group.
Parameters
- title string
- The group heading (markup).
public Size Measure(Constraints constraints, RenderContext context) #Returns the size the widget wants within the constraints.
Parameters
- constraints ConsoleMonster.Layout.Constraints
- The space offered.
- context ConsoleMonster.Canvas.RenderContext
- Profile, theme and glyphs.
public Table PlainRow(params string?[] values) #Adds a row of plain text values (brackets are shown literally).
Parameters
- values string?[]
- The values.
public void Render(Region region, RenderContext context) #Renders into a region. The region may be smaller or larger than the measured size.
Parameters
- region ConsoleMonster.Canvas.Region
- The target region.
- context ConsoleMonster.Canvas.RenderContext
- Profile, theme and glyphs.
public Table Row(params TableCell[] cells) #Adds a row of cells (strings convert to markup cells). Omitted cells show the missing-value marker.
Parameters
- cells ConsoleMonster.Widgets.TableCell[]
- The cells.
public Table Row(TableRowRole role, params TableCell[] cells) #Adds a row with a whole-row tone and emphasis, retaining raw values for presenters and totals.
Parameters
- role ConsoleMonster.Widgets.TableRowRole
- The row role. For a dedicated marker column use RoleTable.
- cells ConsoleMonster.Widgets.TableCell[]
- The original cells, which are not modified.
public Table Values(params object?[] values) #Adds a row of raw values, formatted by the column presenters and summarised by their aggregates.
Parameters
- values object?[]
- The values.
Inherited Methods
Properties
public IReadOnlyList<IWidget> Children { get; } #Widgets held in value cells, including the footer, for dashboard discovery and recording replay.
public bool AutoTotals { get; set; } #With Table.ShowTotals, also sums every column whose values are all numbers (not the key column and not identifier columns such as Id or Port) when it has no TableColumn.Aggregate of its own.
public int? TitleIndent { get; set; } #Optional grid-title indentation in cells; null retains the border-aligned default. Record and card views retain their own title layout.
public bool WrapHeaders { get; set; } #Wrap column headings instead of shortening them (default false).
public bool KeepAllColumns { get; set; } #Keep all columns by rendering consecutive grids with the key repeated when the full grid cannot fit.
public bool HeaderSeparator { get; set; } #Whether a separator row is drawn under the header (default true). When false the header is underlined instead, so data starts on the row directly below it.
public bool GroupHeadersAsRows { get; set; } #Whether group labels occupy full-width section rows instead of labelled border rules (default false).
public bool ShowGroupCounts { get; set; } #Append automatic row counts to group headings (default true).
public int GroupGap { get; set; } #Blank lines before each group after the first (default zero).
public bool Expand { get; set; } #Whether the table fills the available width: the free-text columns share the spare width in proportion to their widths, unless columns set TableColumn.Weight or TableColumn.Flexible; number, date and status columns keep their natural width.
public int CardsBelow { get; set; } #Below this many cells of width the rows render as record cards (key column as the card title); 0 disables cards. Default 60. Cards are used only when the grid cannot fit its minimum widths; they also take over when hiding columns would leave only the key column.
public bool AlwaysCards { get; set; } #Shows the rows as record cards at any width (the Cards view of Show-Console).
public bool ShowCardCount { get; set; } #Show the record count beneath cards (default true). Omitted-row notices remain visible when false.
public int RecordViewRows { get; set; } #A table with at most this many rows renders as a record view (default 1; 0 disables).
public bool ShowKeyField { get; set; } #Also show the complete key as a wrapped field in record/card layouts, where headings may be omitted or truncated. Default false.
public IList<string?>? RowTitles { get; set; } #Titles for the rows in record and card views, by data row index (a null or empty entry uses the key column), so a caller can title a record "pwsh (90836)" while the key column stays the name. Null for none.
public bool StableWidths { get; set; } #Whether column widths never shrink while the same table is re-rendered (live tables; default true), so columns do not jump as values change. Widths still fit the available space.
public bool ShowSubtotals { get; set; } #Whether each group ends with a subtotal row for columns that have an TableColumn.Aggregate.
public bool ShowTotals { get; set; } #Whether a totals row summarises all rows (columns with an TableColumn.Aggregate), unless a footer is set.
public string? TotalLabel { get; set; } #The label of the totals row, or null (default) for the built-in word (Total in English).
public int MaxRows { get; set; } #Shows only the first N rows (0 = all) followed by Showing N of M; totals still cover every row.
public int WrapLines { get; set; } #The most lines a wrapped value uses when its column sets no TableColumn.MaxLines (default 3; 0 = no limit): a long description stays a few lines with an ellipsis instead of taking the screen.
public int? TotalRowCount { get; set; } #The total number of records when the caller added only some of them (for example the first 50 of 1,234), so the footer can say Showing 50 of 1,234; null when every record was added.
public PresentationOptions Presentation { get; set; } #Culture, clock and time zone for raw values.