Unplanned
Last Updated: 23 Dec 2024 14:09 by Garrett
Garrett
Created on: 23 Dec 2024 14:09
Category: Grid
Type: Bug Report
0
DateOnly field cannot be filtered in a Grid configured for OData binding

### Bug report

When the Grid is set up for OData-v4 binding, the columns that bind to DateOnly fields fail to filter. The date value in the filter expression contains the time portion and the following error is thrown:

"The binary operator GreaterThan is not defined for the types 'System.Nullable`1[System.DateOnly]' and 'System.Nullable`1[System.DateTimeOffset]'."

### Reproduction of the problem

1) Create a Grid that uses OData-v4 binding.

2) Bind a specified column to a DateOnly field.

3) Filter the column through the default column filter menu and open the browser DevTools to review the response of the request.

//Model
public DateOnly LastProdUpdate { get; set; }

//View
@(Html.Kendo().Grid<ProductViewModel>()
    .Name("grid")
     .Columns(columns =>
        {
            columns.Bound(p => p.LastProdUpdate).Format("{0:dd/MM/yyyy}");
        })
        ...
        .Filterable()
        .DataSource(dataSource => dataSource
        .Custom()
        .Type("odata-v4")
        .Transport(t =>
        {
            t.Read(read => read.Url("/odata/Products").Data("function() {return {'$expand': 'Employee'} }"));
        })
        .PageSize(10)
        .ServerPaging(true)
        .ServerFiltering(true)
        .ServerSorting(true)
     )
)

### Expected/desired behavior

The DateOnly fields must be filtered successfully as the DateTime fields.

### Environment

* **Kendo UI version: 2024.4.1112
* **Browser: [all]

0 comments