1
votes

I am using this example from Telerik site which demos how to add a filter to your grid. I am following the example exactly how it is shown which is below:

@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.OrderViewModel>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.OrderID).Filterable(ftb => ftb.Cell(cell => cell.ShowOperators(false))).Width(225);
        columns.Bound(p => p.ShipName).Width(500).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
        columns.Bound(p => p.Freight).Width(255).Filterable(ftb => ftb.Cell(cell => cell.Operator("gte")));
        columns.Bound(p => p.OrderDate).Format("{0:MM/dd/yyyy}");
    })
    .Pageable()
    .Sortable()
    .Scrollable()
    .Filterable(ftb => ftb.Mode(GridFilterMode.Row))
    .HtmlAttributes(new { style = "height:550px;" })
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(20)
        .ServerOperation(true)
        .Read(read => read.Action("Orders_Read", "Grid"))
     )
)

However, when I use I run my site, I get an error on line

columns.Bound(p => p.ShipName).Width(500).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains"))); 

saying that "Cannot convert lambda expression to type 'bool' because it is not a delegate type."

I dont know what I am doing wrong as my code is exactly the same as the demo code.

Any help is appreciated!

1
is ShipName is string? Try to remove filterable for shipname and run it and see if it works fine with out error. What exactly you are doing for that column? trying to keep only contains filter? - veena panakanapalli
Yes shipName is a string. I am trying to add a filter to my Grid like what they show on their demo demos.telerik.com/aspnet-mvc/grid/filter-row - wixstar
then I am sure some data is wrong. Please keep debug point and check if all the data is string or not for shipname - veena panakanapalli
I only how one column which is the name and that is the string - wixstar

1 Answers

0
votes

Wixstar

columns.Bound(p => p.ShipName).Width(500).Filterable(ftb=> ftb.Extra(false));

This will work for you,no need to use Operator("...")

if this will help you than mark this answer as correct answer.