Search code examples
filterkendo-uikendo-datasource

Kendo UI datasource filter by comparing fields


I have a Kendo UI DataSource and I want to filter it by comparing fields. This is my datasource:

var dataSource = new kendo.data.DataSource({
  data: [
    { appointment: "Hairdresser", start: new Date("somedate"), end:  new Date("somedate")},
    { appointment: "Meeting", start: new Date("somedate"), end:  new Date("somedate")},
    { appointment: "Shopping", start: new Date("somedate"), end:  new Date("somedate")}
  ]
});

And I want to filter it like this:

SELECT * FROM dataSource WHERE start > end;

dataSource.filter({
                "field": "start",
                "operator": "gt",
                "value": ?????
            });

How can I achieve this using filters?


Solution

  • This is not possible with the built-in filtering. Instead I would suggest you to create a button which on click will send some extra parameters to the server where you can perform such filtering on your own.

    To send additional fields and perform a Read request you can go like this

    dataSource.read({ myCustomFilter:true });