Class TableColumnModelBuilder<T, TKey>
- Namespace
- Htmx.Components.Models.Builders
- Assembly
- Htmx.Components.dll
Provides a fluent API for configuring table columns, including display options, filtering, editing capabilities, and actions. This builder allows detailed customization of how data is presented and interacted with in table views.
public class TableColumnModelBuilder<T, TKey> : BuilderBase<TableColumnModelBuilder<T, TKey>, TableColumnModel<T, TKey>> where T : class
Type Parameters
T
The model type being displayed in the table
TKey
The type of the model's primary key
- Inheritance
-
TableColumnModelBuilder<T, TKey>
- Inherited Members
- Extension Methods
Methods
BuildImpl()
Builds the configured table column model. This method is called internally by the builder framework to create the final column model. Compiles any selector expressions for performance if needed.
protected override Task<TableColumnModel<T, TKey>> BuildImpl()
Returns
- Task<TableColumnModel<T, TKey>>
A task that represents the asynchronous build operation. The task result contains the configured table column model.
WithActions(Action<TableRowContext<T, TKey>, ActionSetBuilder>)
Adds custom actions to this column that will be displayed for each row. Actions are interactive elements like buttons or links that users can click to perform operations. If no custom cell partial view is specified, will use the default action list partial view.
public TableColumnModelBuilder<T, TKey> WithActions(Action<TableRowContext<T, TKey>, ActionSetBuilder> actionsFactory)
Parameters
actionsFactory
Action<TableRowContext<T, TKey>, ActionSetBuilder>A function that configures actions for each row context using an action set builder
Returns
- TableColumnModelBuilder<T, TKey>
The current builder instance for method chaining
WithCellPartial(string)
Specifies a custom partial view to use for rendering the cells in this column. This allows complete customization of how the cell content is displayed.
public TableColumnModelBuilder<T, TKey> WithCellPartial(string cellPartial)
Parameters
cellPartial
stringThe path or name of the partial view to use for cell rendering
Returns
- TableColumnModelBuilder<T, TKey>
The current builder instance for method chaining
WithCrudActions()
Adds standard CRUD (Create, Read, Update, Delete) actions to this column. The available actions depend on the CRUD features enabled in the model handler. In edit mode, shows Save and Cancel actions. In view mode, shows Edit and Delete actions based on permissions.
public TableColumnModelBuilder<T, TKey> WithCrudActions()
Returns
- TableColumnModelBuilder<T, TKey>
The current builder instance for method chaining
WithEditable(bool)
Configures whether this column supports inline editing. When enabled, clicking on cells in this column will display input controls for editing. Requires that an input model builder is registered for this column's property.
public TableColumnModelBuilder<T, TKey> WithEditable(bool isEditable = true)
Parameters
isEditable
boolTrue to enable inline editing, false to disable it
Returns
- TableColumnModelBuilder<T, TKey>
The current builder instance for method chaining
Exceptions
- InvalidOperationException
Thrown when no input model builder is found for this column's property
WithFilter(Func<IQueryable<T>, string, IQueryable<T>>)
Configures a filter function that can be applied to the queryable data source for this column. This enables filtering functionality based on user input for this column.
public TableColumnModelBuilder<T, TKey> WithFilter(Func<IQueryable<T>, string, IQueryable<T>> filter)
Parameters
filter
Func<IQueryable<T>, string, IQueryable<T>>A function that takes the queryable data source and a filter value, returning a filtered queryable
Returns
- TableColumnModelBuilder<T, TKey>
The current builder instance for method chaining
WithFilterPartial(string)
Specifies a custom partial view to use for rendering the filter controls for this column. This allows customization of how filtering UI is presented and also enables editing for the column.
public TableColumnModelBuilder<T, TKey> WithFilterPartial(string filterPartial)
Parameters
filterPartial
stringThe path or name of the partial view to use for filter rendering
Returns
- TableColumnModelBuilder<T, TKey>
The current builder instance for method chaining
WithHeader(string)
Sets the header text displayed for this column in the table. This is the text that appears in the column header row.
public TableColumnModelBuilder<T, TKey> WithHeader(string header)
Parameters
header
stringThe text to display in the column header
Returns
- TableColumnModelBuilder<T, TKey>
The current builder instance for method chaining
WithRangeFilter(Func<IQueryable<T>, string, string, IQueryable<T>>)
Configures a range filter function for columns that support range-based filtering (such as dates or numbers). This allows users to filter data between two values. Currently experimental and may not work as expected.
public TableColumnModelBuilder<T, TKey> WithRangeFilter(Func<IQueryable<T>, string, string, IQueryable<T>> rangeFilter)
Parameters
rangeFilter
Func<IQueryable<T>, string, string, IQueryable<T>>A function that takes the queryable data source and two filter values (start and end), returning a filtered queryable
Returns
- TableColumnModelBuilder<T, TKey>
The current builder instance for method chaining
Remarks
This feature is not fully tested and may require additional work to support different column types properly.