This is a migrated thread and some comments may be shown as answers.

Create template for common filter actions

1 Answer 66 Views
Grid
This is a migrated thread and some comments may be shown as answers.
DonKitchen
Top achievements
Rank 1
DonKitchen asked on 20 Mar 2017, 02:25 PM

Is there a way I can extract this code out into a variable or template so I don't have to define it for each column I want to use it on?

@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.EmployeeViewModel>()   
    .Name("Grid")
    .Columns(columns => {
        columns.Template(@<text>@item.FirstName  @item.LastName</text>)
                .ClientTemplate("#=FirstName# #=LastName#")
                .Title("Name");
        columns.Bound(e => e.City)
                .Filterable(filterable => filterable.UI("cityFilter"))
                .Width(200);
        columns.Bound(e => e.Title)
                .Filterable(filterable => filterable.UI("titleFilter"))
                .Width(350);  
    })   
    .Filterable(filterable => filterable
        .Extra(false)
        .Operators(operators => operators
            .ForString(str => str.Clear()
                .StartsWith("Starts with")
                .IsEqualTo("Is equal to")
                .IsNotEqualTo("Is not equal to")
            ))
        )  
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("FilterMenuCustomization_Read", "Grid"))
     )
)

1 Answer, 1 is accepted

Sort by
0
Preslav
Telerik team
answered on 23 Mar 2017, 01:08 PM
Hello Don,

I am not aware of a way for extracting the desired code.

Further, the highlighted code configurations are defined once per grid in the Filterable property. You do not have to define it for each column separately.

Regards,
Preslav
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
DonKitchen
Top achievements
Rank 1
Answers by
Preslav
Telerik team
Share this question
or