Table of Contents

Class TwDataTableColumn<TItem>

Namespace
TwBlazor.Components
Assembly
TwBlazor.dll

Defines a column in the TwDataTable with its properties and behavior.

public class TwDataTableColumn<TItem>

Type Parameters

TItem

The type of items displayed in the table.

Inheritance
TwDataTableColumn<TItem>
Inherited Members

Constructors

TwDataTableColumn()

public TwDataTableColumn()

Properties

CellClass

Gets or sets additional CSS classes for the data cells.

public string? CellClass { get; set; }

Property Value

string

CellFormatter

Gets or sets a custom render function for the cell content.

public Func<TItem, string>? CellFormatter { get; set; }

Property Value

Func<TItem, string>

EditTemplate

Gets or sets a custom editor for the column, in place of the one chosen from the value's type.

public RenderFragment<TwDataTableCellEditContext<TItem>>? EditTemplate { get; set; }

Property Value

RenderFragment<TwDataTableCellEditContext<TItem>>

Editable

Gets or sets whether the column can be changed when a row is edited, with Editable set. The editor follows the value's type: a text field for text, a number field for numbers, a checkbox for bool, a date picker for DateTime and a list for an enum. Use EditTemplate for any other editor.

public bool Editable { get; set; }

Property Value

bool

ExportFormatter

Gets or sets the value written for the column when the table is exported, in place of PropertySelector. Return a number, date or bool to keep its type in Excel, or a string for text.

public Func<TItem, object?>? ExportFormatter { get; set; }

Property Value

Func<TItem, object>

Exportable

Gets or sets whether the column is included when the table is exported to CSV or Excel. Defaults to true. Set it to false for a column of buttons or other content that only makes sense on screen.

public bool Exportable { get; set; }

Property Value

bool

FilterOperators

Gets or sets the conditions people can choose from, in order, or null for the ones that suit FilterType. The first is chosen when the filter opens.

public IReadOnlyList<FilterOperator>? FilterOperators { get; set; }

Property Value

IReadOnlyList<FilterOperator>

FilterType

Gets or sets the kind of values the column filters, which decides its conditions and value field. Defaults to Auto, which works it out from the PropertySelector values. Set it when the rows come from an ItemsProvider, which may not have loaded any yet.

public FilterType FilterType { get; set; }

Property Value

FilterType

Filterable

Gets or sets whether the column has a filter button in its header. The filter offers one or two conditions, combined with And or Or, that suit the column's values.

public bool Filterable { get; set; }

Property Value

bool

Groupable

Gets or sets whether people can group the rows by this column from the table's Group by list. Rows group by the PropertySelector value, and each group is labelled with CellFormatter when the column has one.

public bool Groupable { get; set; }

Property Value

bool

HeaderClass

Gets or sets additional CSS classes for the header cell.

public string? HeaderClass { get; set; }

Property Value

string

Hideable

Gets or sets whether people can hide the column from the column menu. Defaults to true. Set it to false for a column that identifies each row, such as a name.

public bool Hideable { get; set; }

Property Value

bool

IsSortable

Gets or sets whether this column is sortable.

public bool IsSortable { get; set; }

Property Value

bool

Name

Gets or sets the unique name/key for the column.

public string Name { get; set; }

Property Value

string

PropertySelector

Gets or sets the property selector expression for accessing the column value.

public Func<TItem, object?>? PropertySelector { get; set; }

Property Value

Func<TItem, object>

Resizable

Gets or sets whether people can resize the column by its border when ResizableColumns is enabled. Defaults to true.

public bool Resizable { get; set; }

Property Value

bool

Title

Gets or sets the display title for the column header.

public string Title { get; set; }

Property Value

string

Validator

Gets or sets a check run on the new value when a row is saved. Return a message saying what to fix, or null when the value is fine. The row is not saved while any column reports a problem.

public Func<TItem, object?, string?>? Validator { get; set; }

Property Value

Func<TItem, object, string>

ValueSetter

Gets or sets how a saved value is written back to the row, such as (product, value) => product.Price = (decimal)value!. Without it the new values only reach RowSaved.

public Action<TItem, object?>? ValueSetter { get; set; }

Property Value

Action<TItem, object>

Visible

Gets or sets whether the column is shown when the table first renders, or after its columns are reset. Defaults to true. People can show or hide it from a column's menu when ColumnMenu is enabled.

public bool Visible { get; set; }

Property Value

bool

Width

Gets or sets the width of the column as any CSS length, such as 12rem, 160px or 25%. When any column has a width, the table renders a TwTableColumn for every column.

public string? Width { get; set; }

Property Value

string