简体   繁体   English

查询Kendo UI数据源

[英]Query Kendo UI DataSource

I want to use the DataSource as a local DB where by I can query certain data. 我想将DataSource用作本地数据库,可以在其中查询某些数据。 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 谢谢

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: 针对您的方案的一个简单解决方案是创建一个新的DS,该DS创建数据的副本,然后查询:

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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM