Skip to content
ConsoleMonster
Class

Grid

ConsoleMonster.Interactive

Namespace
ConsoleMonster.Interactive
Assembly
ConsoleMonster
Modifiers
sealed
Attributes
Fluent

An interactive table viewer: filter as you type, sort by column, page and scroll, mark rows, choose columns, and see a row's details. It returns the original objects of the chosen rows. Columns use the table's width negotiation and presenters; the screen has the same header bar, panel and footer as menus and forms.

Inheritance

  • object
  • Grid

Usage

Explore 24 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Returned or exposed by 11

Accepted by parameters 13

Constructors

public Grid(string title) #

Creates a grid.

Parameters

title string required
The title in the header bar.

Methods

Column 2 overloads
public Grid Column(TableColumn column) #

Adds a column.

Parameters

column ConsoleMonster.Widgets.TableColumn required
The column (header, presenter, alignment, priority).

Returns

Grid The grid.
public Grid Column(string header, ICellPresenter? presenter = null) #

Adds a column by header.

Parameters

header string required
The header.
presenter ConsoleMonster.Presenters.ICellPresenter? = null optional
The presenter, or null for automatic formatting.

Returns

Grid The grid.
Row 2 overloads
public Grid Row(object? item, params object?[] values) #

Adds a row: the object it stands for and its raw column values.

Parameters

item object? required
The object returned when the row is chosen.
values object?[] required
The column values (formatted by the column presenters).

Returns

Grid The grid.
public Grid Row(GridRow row) #

Adds a row with an explicit stable identity, including lazy cells.

Parameters

row ConsoleMonster.Interactive.GridRow required

Returns

Grid
public void SetRows(IEnumerable<GridRow> rows) #

Replaces a listing. Reuse row identities to retain a DataGrid's cursor and marks.

Parameters

rows System.Collections.Generic.IEnumerable<ConsoleMonster.Interactive.GridRow> required
Show 2 overloads
public GridResult Show(Action<GridOptions> configure, CancellationToken cancellationToken = default) #

Shows this grid with freshly configured options.

Parameters

configure System.Action<ConsoleMonster.Interactive.GridOptions> required
Grid settings.
cancellationToken System.Threading.CancellationToken = default optional
Cancellation.

Returns

GridResult The grid result.
public GridResult Show(GridOptions? options = null, CancellationToken cancellationToken = default) #

Shows the grid and returns the chosen rows.

Parameters

options ConsoleMonster.Interactive.GridOptions? = null optional
The options, or null for the defaults.
cancellationToken System.Threading.CancellationToken = default optional
Cancels the grid.

Returns

GridResult The result.
public GridResult ShowInBrowser(GridOptions? options = null, BrowserGridOptions? browser = null, CancellationToken cancellationToken = default) #

Shows the grid in the default browser and returns the chosen rows' original objects. The page is served from 127.0.0.1 on a random port behind a one-time token, loads nothing external, and offers the same filter, sort and selection as the screen grid. Commands and row refresh are screen-only. Lazy cells are computed before the page opens. Sessions where nobody can answer (InteractionMode.None or InteractionMode.Snapshot, a non-interactive flag, or CI) never open a browser.

Parameters

options ConsoleMonster.Interactive.GridOptions? = null optional
Filter, sort, hidden columns and interaction options; null for the defaults.
browser ConsoleMonster.Interactive.BrowserGridOptions? = null optional
How the page opens and how long to wait; null for the defaults.
cancellationToken System.Threading.CancellationToken = default optional
Stops waiting and closes the listener.

Returns

GridResult Accepted with the chosen items, or not accepted when the page was cancelled or closed.

Exceptions

Properties

public string Title { get; set; } #

The title.

public GridSelection OutputMode { get; set; } #

What the grid returns (default GridSelection.Multiple).

public PresentationOptions Presentation { get; set; } #

Culture and display options for the presenters.

public IReadOnlyList<TableColumn> Columns { get; } #

The columns.

public IReadOnlyList<GridRow> Rows { get; } #

The rows.

Extension Methods

public static Grid OutputMode(Grid grid, GridSelection value) #

Sets Grid.OutputMode: What the grid returns (default GridSelection.Multiple).

Parameters

grid ConsoleMonster.Interactive.Grid required
The instance.
value ConsoleMonster.Interactive.GridSelection required
The value.

Returns

Grid The same instance.

Examples

// C# initializer or property    // C# fluent
grid.OutputMode = value;         Ui.Grid().OutputMode(value);
Presentation 2 overloads
public static Grid Presentation(Grid grid, PresentationOptions value) #

Sets Grid.Presentation: Culture and display options for the presenters.

Parameters

grid ConsoleMonster.Interactive.Grid required
The instance.
value ConsoleMonster.Presenters.PresentationOptions required
The value.

Returns

Grid The same instance.

Examples

// C# initializer or property    // C# fluent
grid.Presentation = value;       Ui.Grid().Presentation(value);
public static Grid Presentation(Grid grid, Action<PresentationOptions> configure) #

Configures Grid.Presentation in place (creating it when not set): Culture and display options for the presenters.

Parameters

grid ConsoleMonster.Interactive.Grid required
The instance.
configure System.Action<ConsoleMonster.Presenters.PresentationOptions> required
Configures the value.

Returns

Grid The same instance.
public static Grid Title(Grid grid, string value) #

Sets Grid.Title: The title.

Parameters

grid ConsoleMonster.Interactive.Grid required
The instance.
value string required
The value.

Returns

Grid The same instance.

Examples

// C# initializer or property    // C# fluent
grid.Title = value;              Ui.Grid().Title(value);