Search code examples
jquerykendo-uikendo-gridkendo-datasource

Query Kendo UI DataSource


I want to use the DataSource as a local DB where by I can query certain data. I tried the following:

this.get("productsSource").query({
    filter: { field: "dirty", operator: "eq", value: true} 
});
var dirty = this.get("productsSource").view();

This works great. However, the Drop Down List bound to this DataSource is now showing only the "dirty" records. As if the query affected the entire DataSource.

What I am after is to just return certain records based on a filter criteria without changing the "view" of the DataSource.

Is that doable?

Thanks


Solution

  • That's how it's designed; a simple solution for your scenario would be to create a new DS which creates a copy of the data, then query that:

    var originalDS = this.get("productsSource");
    var filterDS = new kendo.data.DataSource({ data: originalDS.data() });
    var dirty = filterDS.query({
        filter: { field: "dirty", operator: "eq", value: true} 
    }).view();