API Reference
Table
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 whose columns are read from typed items.
Inheritance
- Object
- Table
Constructors
public Table() #Methods
public Table AddColumn(String header, HorizontalAlignment? alignment = null) #TableAdds a column.
Parameters
- header System.String
- The header (markup).
- alignment ConsoleMonster.Layout.HorizontalAlignment? = null
- Alignment, or null for automatic.
Returns
This instance.
public Table AddColumn(TableColumn column) #TableAdds a column definition.
Parameters
- column ConsoleMonster.Widgets.TableColumn
- The column.
Returns
This instance.
public Table AddGroup(String title) #TableStarts a group: rows added after this belong to it until the next group.
Parameters
- title System.String
- The group heading (markup).
Returns
This instance.
public Table AddPlainRow(params String?[] values) #TableAdds a row of plain text values (brackets are shown literally).
Parameters
- values System.String?[]
- The values.
Returns
This instance.
public Table AddRow(params TableCell[] cells) #TableAdds a row of cells (strings convert to markup cells). Missing cells are blank.
Parameters
- cells ConsoleMonster.Widgets.TableCell[]
- The cells.
Returns
This instance.
public Table AddValues(params Object?[] values) #TableAdds a row of raw values, formatted by the column presenters and summarised by their aggregates.
Parameters
- values System.Object?[]
- The values.
Returns
This instance.
public Void ClearRows() #VoidRemoves every row (columns, options and remembered column widths stay), so the table can be refilled.
public static Table<T?> For<T>(IEnumerable<T?> items) #Table<T?>Makes a table from typed items. Add columns with Table.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.
Returns
The table.
public Size Measure(Constraints constraints, RenderContext context) #SizeReturns the size the widget wants within the constraints.
Parameters
- constraints ConsoleMonster.Layout.Constraints
- The space offered.
- context ConsoleMonster.Canvas.RenderContext
- Profile, theme and glyphs.
Returns
The desired size, never larger than the constraints.
public Void Render(Region region, RenderContext context) #VoidRenders 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.
Inherited Methods
public virtual Boolean Equals(Object? obj) #BooleanParameters
- obj Object?
Properties
public Boolean 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 Boolean 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 Boolean Expand { get; set; } #Whether the table fills the available width (spare width goes to the flexible column).
public Int32 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 Boolean AlwaysCards { get; set; } #Shows the rows as record cards at any width (the Cards view of Show-Console).
public Int32 RecordViewRows { get; set; } #A table with at most this many rows renders as a record view (default 1; 0 disables).
public Boolean 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 Boolean ShowSubtotals { get; set; } #Whether each group ends with a subtotal row for columns that have an TableColumn.Aggregate.
public Boolean 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 Int32 MaxRows { get; set; } #Shows only the first N rows (0 = all) followed by Showing N of M; totals still cover every row.
public Int32? 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.