Table of Contents

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

FilterValueCollection

Methods

ConvertFilterValues(FilterValueCollection)

Converts a FilterValueCollection to another value collection if needed by the provider.

protected virtual FilterValueCollection ConvertFilterValues(FilterValueCollection values)

Parameters

values FilterValueCollection

The 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 string

The filter label.

filterName string

The name of the filter used to identify it from other filters.

category string

The category to group filters under.

filterOperator FilterOperator

The operator to use to compares values.

fallbackValue object

The fallback value of the filter.

Returns

FilterDefinition

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

filterName string

The name of the filter definition to create a filter for. Corresponds to Name.

Returns

FilterBase

GetFilterDefinitions()

Gets filter definitions.

protected virtual IEnumerable<FilterDefinition> GetFilterDefinitions()

Returns

IEnumerable<FilterDefinition>

GetFilterMap()

Gets the name map for the filters.

public Dictionary<string, string>? GetFilterMap()

Returns

Dictionary<string, string>

GetFilterNameMap()

Gets a map from filter name to the underlying model property name.

protected virtual Dictionary<string, string>? GetFilterNameMap()

Returns

Dictionary<string, string>

GetFilters()

Gets the filters.

public IEnumerable<FilterBase> GetFilters()

Returns

IEnumerable<FilterBase>

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 TListModel

The 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.

To top