Class TableModelBuilder<T, TKey>
- Namespace
- Htmx.Components.Models.Builders
- Assembly
- Htmx.Components.dll
Abstracts the process of creating a TableModel<T, TKey>
public class TableModelBuilder<T, TKey> : BuilderBase<TableModelBuilder<T, TKey>, TableModel<T, TKey>> where T : class
Type Parameters
T
The entity type
TKey
The key type
- Inheritance
-
TableModelBuilder<T, TKey>
- Inherited Members
- Extension Methods
Methods
AddCrudDisplayColumn(string)
Adds a display-only column with standard CRUD actions (Edit, Delete) to the table. This is a convenience method that creates an action column with the default CRUD operations.
public TableModelBuilder<T, TKey> AddCrudDisplayColumn(string header = "Actions")
Parameters
header
stringThe header text for the actions column (defaults to "Actions")
Returns
- TableModelBuilder<T, TKey>
The current builder instance for method chaining
AddDisplayColumn(string, Action<TableColumnModelBuilder<T, TKey>>?)
Adds a TableColumnModel configured to be used as a display column
public TableModelBuilder<T, TKey> AddDisplayColumn(string header, Action<TableColumnModelBuilder<T, TKey>>? configure = null)
Parameters
header
stringconfigure
Action<TableColumnModelBuilder<T, TKey>>
Returns
- TableModelBuilder<T, TKey>
AddSelectorColumn(Expression<Func<T, object>>, Action<TableColumnModelBuilder<T, TKey>>?)
Adds a TableColumnModel configured to be used as a value selector
public TableModelBuilder<T, TKey> AddSelectorColumn(Expression<Func<T, object>> selector, Action<TableColumnModelBuilder<T, TKey>>? configure = null)
Parameters
selector
Expression<Func<T, object>>The property selector expression
configure
Action<TableColumnModelBuilder<T, TKey>>Optional configuration action for the column
Returns
- TableModelBuilder<T, TKey>
The table model builder for method chaining
BuildImpl()
Builds the configured table model and performs final setup operations. This method sets up column relationships, configures default filtering for filterable columns, and enables editing for columns that have input models and appropriate CRUD permissions.
protected override Task<TableModel<T, TKey>> BuildImpl()
Returns
- Task<TableModel<T, TKey>>
A task that represents the asynchronous build operation. The task result contains the configured table model.
WithActions(Action<TableModel<T, TKey>, ActionSetBuilder>)
Adds table-level actions that appear above the table (such as "Add New" buttons). These actions operate on the entire table rather than individual rows.
public TableModelBuilder<T, TKey> WithActions(Action<TableModel<T, TKey>, ActionSetBuilder> actionsFactory)
Parameters
actionsFactory
Action<TableModel<T, TKey>, ActionSetBuilder>A function that configures table-level actions using an action set builder
Returns
- TableModelBuilder<T, TKey>
The current builder instance for method chaining
WithCrudActions()
Adds standard CRUD table-level actions to the table. Currently adds an "Add New" action if the model handler supports Create operations. The actions are based on the CRUD features enabled in the model handler.
public TableModelBuilder<T, TKey> WithCrudActions()
Returns
- TableModelBuilder<T, TKey>
The current builder instance for method chaining
WithTypeId(string)
Sets the unique type identifier for this table model. This identifier is used for routing, authorization, and UI component registration.
public TableModelBuilder<T, TKey> WithTypeId(string typeId)
Parameters
typeId
stringA unique string identifier for the model type
Returns
- TableModelBuilder<T, TKey>
The current builder instance for method chaining