Table of Contents

Class TwTableColumn

Namespace
TwBlazor.Components
Assembly
TwBlazor.dll

Defines one or more columns of a TwTable, rendered as a <col> element inside the table's ColumnGroup.

public class TwTableColumn : TwBlazorComponentBase, IComponent, IHandleEvent, IHandleAfterRender, ITwComponent, IDisposable
Inheritance
TwTableColumn
Implements
Inherited Members

Remarks

A column takes a width without any Tailwind class, so it works from any project. With the default automatic layout the width is the narrowest the column will go, so long or breakable content in other columns cannot squeeze it. With FixedLayout the width is exact. Columns without a width share whatever space is left.

Constructors

TwTableColumn()

public TwTableColumn()

Properties

Label

Gets or sets the column's name for assistive technology, used to name its resize border ("Resize Price"). Set it to the column's heading.

[Parameter]
public string? Label { get; set; }

Property Value

string

MaxWidth

Gets or sets the widest a person can make the column by resizing it, in pixels. Defaults to 2000.

[Parameter]
public int MaxWidth { get; set; }

Property Value

int

MinWidth

Gets or sets the narrowest a person can make the column by resizing it, in pixels. Defaults to 48.

[Parameter]
public int MinWidth { get; set; }

Property Value

int

Resizable

Gets or sets whether people can resize this column when the table's ResizableColumns is set. Defaults to true. A column that spans several columns is never resizable.

[Parameter]
public bool Resizable { get; set; }

Property Value

bool

Span

Gets or sets how many consecutive columns this definition covers. Defaults to 1.

[Parameter]
public int Span { get; set; }

Property Value

int

Width

Gets or sets the width of the column as any CSS length, such as 12rem, 160px or 25%. Leave it unset to size the column from the remaining space.

[Parameter]
public string? Width { get; set; }

Property Value

string

WidthChanged

Raised with the column's new width, such as 180px, after a person resizes it. Bind it with @bind-Width to keep the width.

[Parameter]
public EventCallback<string> WidthChanged { get; set; }

Property Value

EventCallback<string>

Methods

BuildRenderTree(RenderTreeBuilder)

Renders the component to the supplied RenderTreeBuilder.

protected override void BuildRenderTree(RenderTreeBuilder __builder)

Parameters

__builder RenderTreeBuilder

Dispose()

Leaves the table, so it stops applying widths to this column.

public void Dispose()

Dispose(bool)

Removes the column from its table, so the table stops resizing it.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

true when called from Dispose().

OnParametersSet()

Invoked when the component's parameters have been set. Ensures that the component has a unique identifier by generating one if none is provided.

protected override void OnParametersSet()

Remarks

If the component's identifier is not set, a unique ID is generated based on the component's type name (with a 'Tw' prefix removed if present) and a GUID. This helps ensure that each component instance can be uniquely identified, which is useful for scenarios such as associating labels with form elements or targeting elements in client-side scripts.