Search code examples
asp.net-mvckendo-uikendo-ui-mvc

How can I remove filter operators from kendo mvc grid


I have a kendo mvc grid with a datetime column.

The filters for "is greater than" or "is smaller than" does work on the datetime cell values but NOT the "is equal to" filter.

I want to remove the isequal filter therefore.

How can I do this?


Solution

  • You can use filterable.operators.string option

    <div id="grid"></div>
    <script>
    
    $("#grid").kendoGrid({
      columns: [
        { field: "name" }
      ],
      dataSource: [
        { name: "Jane Doe" },
        { name: "John Doe" }
      ],
      filterable: {
        operators: {
          string: {
            eq: "Equal to",
            neq: "Not equal to"
          }
        }
      }
    });
    </script>
    

    Using MVC wrapper you can use:

    .Filterable(filterable => filterable
        .Extra(false)
         .Operators(operators => operators
            .ForString(str => str.Clear()
                .StartsWith("Starts with")
                .IsEqualTo("Is equal to")
                .IsNotEqualTo("Is not equal to")
            ))
        )