Class TableColumnHelper
- Namespace
- Htmx.Components.Table.Models
- Assembly
- Htmx.Components.dll
Provides utility methods for table column operations including filtering and value parsing.
public static class TableColumnHelper
- Inheritance
-
TableColumnHelper
- Inherited Members
Remarks
This static class contains methods for applying dynamic filters to queryables based on string filter expressions. It supports various operators and data types commonly used in table filtering scenarios.
Methods
Filter<T, TKey>(IQueryable<T>, string, TableColumnModel<T, TKey>)
Applies a filter string to the queryable using column metadata from the table model.
public static IQueryable<T> Filter<T, TKey>(IQueryable<T> query, string filter, TableColumnModel<T, TKey> column) where T : class
Parameters
query
IQueryable<T>The queryable to apply the filter to.
filter
stringThe filter expression string.
column
TableColumnModel<T, TKey>The column model containing metadata for filtering.
Returns
- IQueryable<T>
A filtered queryable with the specified filter applied.
Type Parameters
T
The entity type being filtered.
TKey
The key type for the entity.
Examples
// Filter for names containing "John"
var filtered = TableColumnHelper.Filter(query, "contains John", nameColumn);
// Filter for ages between 18 and 65
var filtered = TableColumnHelper.Filter(query, "between 18, 65", ageColumn);
// Filter for dates after a specific date
var filtered = TableColumnHelper.Filter(query, "> 2023-01-01", dateColumn);
Remarks
Filter syntax: [Operator] [Operand1], [Operand2]
Supported operators: - Comparison: =, ==, !=, <, >, <=, >= - String operations: contains, startswith, endswith - Null checks: isnull, isnotnull, isnullorempty, isnotnullorempty - Range: between [value1], [value2]
Operands can be: - Quoted strings: "some value" - Unquoted values: 123, true, 2023-01-01 - Column references: [Other Column Name]