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
TModel
The 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
values
FilterValueCollectionThe 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
expression
Expression<Func<TModel, TValue>>The expression identifying the property for the filter definition.
label
stringThe filter label.
filterName
stringThe name of the filter used to identify it from other filters.
category
stringThe category to group filters under.
filterOperator
FilterOperatorThe operator to use to compares values.
fallbackValue
objectThe fallback value of the filter.
Returns
Type Parameters
TValue
The type of the property used for the filter definition.
Exceptions
- ArgumentException
Throws if the property given is not specified to be filterable.
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
excludedFilters
IEnumerable<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
listModel
TListModelThe model in this filter provider as
TListModel
if possible.
Returns
- bool
true
if the model is valid;false
otherwise.
Type Parameters
TListModel
The type of the model to get.