New to Telerik UI for ASP.NET MVC? Start a free 30-day trial

Defines the fluent API for configuring the Kendo Filter for ASP.NET MVC.

Definition

Constructors

Initializes a new instance of the Filter class.

C#
public FilterBuilder(Filter<T> component)
Parameters:componentFilter<T>

The component.

Methods

If set to true the filter will display a button which when clicked will apply filtering over the datasource.

C#
public FilterBuilder<T> ApplyButton()
Returns:

FilterBuilder<T>

Example:
C#
@(Html.Kendo().Filter&lt;ProductViewModel&gt;()
.Name("filter")
.ApplyButton()
)

If set to true the filter will display a button which when clicked will apply filtering over the datasource.

C#
public FilterBuilder<T> ApplyButton(bool value)
Parameters:valuebool

The value that configures the applybutton.

Returns:

FilterBuilder<T>

Example:
C#
@(Html.Kendo().Filter&lt;ProductViewModel&gt;()
.Name("filter")
.ApplyButton()
)

The data source to which the widget will apply a filter. Should be an existing kendo.data.DataSource instance.

C#
public FilterBuilder<T> DataSource(string value)
Parameters:valuestring

The value for DataSource

Returns:

FilterBuilder<T>

Example:
C#
@(Html.Kendo().Filter&lt;ProductViewModel&gt;()
.Name("filter")
.Fields(fields =&gt;
{
fields.Add(product =&gt; product.ProductName).Label("ProductName");
})
.DataSource("filterDataSource")
)
C#
public FilterBuilder<T> Events(Action<FilterEventBuilder> configurator)
Parameters:configuratorAction<FilterEventBuilder>Returns:

FilterBuilder<T>

If set to true the filter will visualize the filter expression that will be applied to the datasource.

C#
public FilterBuilder<T> ExpressionPreview()
Returns:

FilterBuilder<T>

Example:
C#
@(Html.Kendo().Filter&lt;ProductViewModel&gt;()
.Name("filter")
.ExpressionPreview()
)

If set to true the filter will visualize the filter expression that will be applied to the datasource.

C#
public FilterBuilder<T> ExpressionPreview(bool value)
Parameters:valuebool

The value that configures the expressionpreview.

Returns:

FilterBuilder<T>

Example:
C#
@(Html.Kendo().Filter&lt;ProductViewModel&gt;()
.Name("filter")
.ExpressionPreview()
)

The configuration of the filter fields. An array of JavaScript objects that hold information regarding the filter field, it's editor, default values used for filter and etc.

C#
public FilterBuilder<T> Fields(Action<FilterFieldFactory<T>> configurator)
Parameters:configuratorAction<FilterFieldFactory<T>>

The configurator for the fields setting.

Returns:

FilterBuilder<T>

Example:
C#
@(Html.Kendo().Filter&lt;ProductViewModel&gt;()
.Name("filter")
.Fields(fields =&gt;
{
fields.Add(product =&gt; product.ProductName).Label("ProductName");
})
)

An object which represents a filter expression which the kendo.data.DataSource can use to filter the data.

C#
public FilterBuilder<T> FilterExpression(Action<DataSourceFilterDescriptorFactory<T>> configurator)
Parameters:configuratorAction<DataSourceFilterDescriptorFactory<T>>Returns:

FilterBuilder<T>

Example:
C#
@(Html.Kendo().Filter&lt;ProductViewModel&gt;()
.Name("filter")
.Fields(fields =&gt;
{
fields.Add(product =&gt; product.ProductName).Label("ProductName");
})
.FilterExpression(filter =&gt;
{
filter.Add(p =&gt; p.ProductName).IsGreaterThanOrEqualTo(5);
})
)

An object which represents a filter expression which the kendo.data.DataSource can use to filter the data.

C#
public FilterBuilder<T> FilterExpression(CompositeFilterDescriptor value)
Parameters:valueCompositeFilterDescriptor

The value for Expression

Returns:

FilterBuilder<T>

Example:
C#
@{

FilterDescriptor filterDescriptor = FilterDescriptor()
{
Member = "ProductName",
CaseSensitiveFilter = true,
Value = "Chai",
MemberType = typeof(string),
Operator = FilterOperator.IsEqualTo
};

CompositeFilterDescriptor compositeFilterDescriptor = new CompositeFilterDescriptor()
{
FilterDescriptors = new FilterDescriptorCollection
{
filterDescriptor
},
CaseSensitiveFilter = true,
LogicalOperator = FilterCompositionLogicalOperator.Or
};
}


@(Html.Kendo().Filter&lt;ProductViewModel&gt;()
.Name("filter")
.Fields(fields =&gt;
{
fields.Add(product =&gt; product.ProductName).Label("ProductName");
})
.FilterExpression(@compositeFilterDescriptor)
)

Defines the value of the logical operator at the root level of the filter expression.

C#
public FilterBuilder<T> MainLogic(FilterCompositionLogicalOperator value)
Parameters:valueFilterCompositionLogicalOperator

The value that configures the mainlogic.

Returns:

FilterBuilder<T>

C#
public FilterBuilder<T> Messages(Action<FilterMessagesSettingsBuilder<T>> configurator)
Parameters:configuratorAction<FilterMessagesSettingsBuilder<T>>Returns:

FilterBuilder<T>

The text of the filter operators displayed in the filter.

C#
public FilterBuilder<T> Operators(Action<FilterOperatorsSettingsBuilder> configurator)
Parameters:configuratorAction<FilterOperatorsSettingsBuilder>

The configurator for the operators setting.

Returns:

FilterBuilder<T>

Example:
C#
@(Html.Kendo().Filter&lt;ProductViewModel&gt;()
.Name("filter")
.Fields(fields =&gt;
{
fields.Add(field =&gt; field.ProductName).Label("ProductName");
})
.Operators(operators =&gt;
{
operators.String(s =&gt;
{
s.Contains("Contains")
.Startswith("Starts with")
.Endswith("Ends with")
.Eq("Equals")
.Neq("Does not equal")
.Isnull("Is null")
.Isnotnull("Is not null")
.Isnotempty("Is not empty")
.Isnullorempty("Is null or empty")
.Isnotnullorempty("Is not null or empty")
.Contains("Contains")
.Doesnotcontain("Does not contain");
}
);
})
.FilterExpression(filter =&gt;
{
filter.Add(field =&gt; field.ProductName).Contains("Cha");
})
)