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

FilterBuilder

Methods

ApplyButton(System.Boolean)

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

Parameters

value - System.Boolean

The value that configures the applybutton.

ExpressionPreview(System.Boolean)

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

Parameters

value - System.Boolean

The value that configures the expressionpreview.

MainLogic(Kendo.Mvc.FilterCompositionLogicalOperator)

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

Parameters

value - FilterCompositionLogicalOperator

The value that configures the mainlogic.

Operators(System.Action)

The text of the filter operators displayed in the filter.

Parameters

configurator - System.Action<FilterOperatorsSettingsBuilder>

The configurator for the operators setting.

Example


               @(Html.Kendo().Filter<ProductViewModel>()
                   .Name("filter")
                   .Fields(fields =>
                   {
                        fields.Add(field => field.ProductName).Label("ProductName");
                   })
                   .Operators(operators =>
                   {
                           operators.String(s =>
                           {
                                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 =>
                   {
                       filter.Add(field => field.ProductName).Contains("Cha");
                   })
               )

Fields(System.Action)

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.

Parameters

configurator - System.Action<FilterFieldFactory>

The configurator for the fields setting.

Example


               @(Html.Kendo().Filter<ProductViewModel>()
                   .Name("filter")
                   .Fields(fields =>
                   {
                        fields.Add(product => product.ProductName).Label("ProductName");
                   })
               )

DataSource(System.String)

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

Parameters

value - System.String

The value for DataSource

Example


               @(Html.Kendo().Filter<ProductViewModel>()
                   .Name("filter")
                   .Fields(fields =>
                   {
                        fields.Add(product => product.ProductName).Label("ProductName");
                   })
                   .DataSource("filterDataSource")
               )

ApplyButton()

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

FilterExpression(Kendo.Mvc.CompositeFilterDescriptor)

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

Parameters

value - CompositeFilterDescriptor

The value for Expression

Example


                @{

                    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<ProductViewModel>()
                    .Name("filter")
                    .Fields(fields =>
                    {
                         fields.Add(product => product.ProductName).Label("ProductName");
                    })
                    .FilterExpression(@compositeFilterDescriptor)
                )

ExpressionPreview()

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

FilterExpression(System.Action)

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

Parameters

configurator - System.Action<DataSourceFilterDescriptorFactory>

Example


               @(Html.Kendo().Filter<ProductViewModel>()
                   .Name("filter")
                   .Fields(fields =>
                   {
                        fields.Add(product => product.ProductName).Label("ProductName");
                   })
                   .FilterExpression(filter =>
                   {
                       filter.Add(p => p.ProductName).IsGreaterThanOrEqualTo(5);
                   })
               )

Events(System.Action)

Parameters

configurator - System.Action<FilterEventBuilder>

Messages(System.Action)

Parameters

configurator - System.Action<FilterMessagesSettingsBuilder>

ToComponent()

Returns the internal view component.

Name(System.String)

Sets the name of the component.

Parameters

componentName - System.String

The name of the component.

Example


            @(Html.Kendo().Grid<OrderViewModel>()
               .Name("grid")
               .Columns(columns =>
               {
                   columns.Bound(p => p.OrderID).Filterable(false);
                   columns.Bound(p => p.Freight);
               })
               .DataSource(dataSource => dataSource
                   .Ajax()
                   .PageSize(20)
                   .Read(read => read.Action("Orders_Read", "Grid"))
               )
            )

Deferred(System.Boolean)

Suppress initialization script rendering. Note that this options should be used in conjunction with

Parameters

deferred - System.Boolean

ModelMetadata(System.Web.Mvc.ModelMetadata)

Uses the Metadata of the Model.

Parameters

modelMetadata - System.Web.Mvc.ModelMetadata

The metadata set for the Model

HtmlAttributes(System.Object)

Sets the HTML attributes.

Parameters

attributes - System.Object

The HTML attributes.

HtmlAttributes(System.Collections.Generic.IDictionary)

Parameters

attributes - System.Collections.Generic.IDictionary<String,Object>

AsModule(System.Boolean)

Specifies whether the initialization script of the component will be rendered as a JavaScript module.

Parameters

value - System.Boolean

Render()

Renders the component.

Example


            @(@Page Inherits="System.Web.Mvc.ViewPage<IEnumerable<Product>>" )
            @( Html.Kendo().Grid(Model)
                .Name("grid")
                .DetailTemplate(product => {
                    )
                       Product Details:
                       <div>Product Name: @( product.ProductName )</div>
                       <div>Units In Stock: @( product.UnitsInStock )</div>
                    @(
                })
                .Render();
            )

ScriptAttributes(System.Object,System.Boolean)

Sets the JavaScript attributes to the initialization script.

Parameters

attributes - System.Object

The JavaScript attributes.

overrideAttributes - System.Boolean

Argument which determines whether attributes should be overriden.

ScriptAttributes(System.Collections.Generic.IDictionary,System.Boolean)

Sets the JavaScript attributes to the initialization script.

Parameters

attributes - System.Collections.Generic.IDictionary<String,Object>

The JavaScript attributes.

overrideAttributes - System.Boolean

Argument which determines whether attributes should be overriden.

ToHtmlString()

ToClientTemplate()

In this article
Not finding the help you need?