Class FilterProvider<TModel>
- Namespace
- Dynamicweb.CoreUI.Data.Filtering
- Assembly
- Dynamicweb.CoreUI.dll
Base class for creating filters for a model.
public abstract class FilterProvider<TModel> where TModel : DataViewModelBase
Type Parameters
TModelThe model the provider is implemented for.
- Inheritance
-
FilterProvider<TModel>
- Inherited Members
Properties
Values
The value collection for filters. Can be used to get the current values for active filters.
public FilterValueCollection? Values { get; }
Property Value
Methods
ConvertFilterValues(FilterValueCollection)
Converts a FilterValueCollection to another value collection if needed by the provider.
protected virtual FilterValueCollection ConvertFilterValues(FilterValueCollection values)
Parameters
valuesFilterValueCollectionThe value collection to convert.
Returns
- FilterValueCollection
Converted value collection.
CreateFilterDefinition<TValue>(Expression<Func<TModel, TValue>>, string?, string?, string?, FilterOperator, object?)
Create a filter definition.
protected FilterDefinition CreateFilterDefinition<TValue>(Expression<Func<TModel, TValue>> expression, string? label = null, string? filterName = null, string? category = null, FilterOperator filterOperator = FilterOperator.Equals, object? fallbackValue = null)
Parameters
expressionExpression<Func<TModel, TValue>>The expression identifying the property for the filter definition.
labelstringThe filter label.
filterNamestringThe name of the filter used to identify it from other filters.
categorystringThe category to group filters under.
filterOperatorFilterOperatorThe operator to use to compares values.
fallbackValueobjectThe fallback value of the filter.
Returns
Type Parameters
TValueThe type of the property used for the filter definition.
Exceptions
- ArgumentException
Throws if the property given is not specified to be filterable.
GetDefaultFilterValues()
protected virtual FilterValueCollection? GetDefaultFilterValues()
Returns
GetFilter(string)
Creates a filter for the definition with the given name.
protected virtual FilterBase? GetFilter(string filterName)
Parameters
Returns
GetFilterDefinitions()
Gets filter definitions.
protected virtual IEnumerable<FilterDefinition> GetFilterDefinitions()
Returns
GetFilterMap()
Gets the name map for the filters.
public Dictionary<string, string>? GetFilterMap()
Returns
GetFilterNameMap()
Gets a map from filter name to the underlying model property name.
protected virtual Dictionary<string, string>? GetFilterNameMap()
Returns
GetFilters()
Gets the filters.
public IEnumerable<FilterBase> GetFilters()
Returns
SetExcludedFilters(IEnumerable<string>?)
Allows setting filters to exclude.
public void SetExcludedFilters(IEnumerable<string>? excludedFilters)
Parameters
excludedFiltersIEnumerable<string>The filters to exclude.
TryGetModel<TListModel>(out TListModel?)
Tries to get the model from the filter provider as the given type.
protected bool TryGetModel<TListModel>(out TListModel? listModel) where TListModel : DataListViewModel<TModel>
Parameters
listModelTListModelThe model in this filter provider as
TListModelif possible.
Returns
- bool
trueif the model is valid;falseotherwise.
Type Parameters
TListModelThe type of the model to get.