【发布时间】:2013-03-16 03:22:37
【问题描述】:
环境:
- 剑道版本:2013.1.319
-
数据源:
productsDataSource = new kendo.data.DataSource({ type: "odata", transport: { read: "http://www.mydomain.com/odata.svc/products", dataType: "json", contentType: "application/json" } schema: { type: "json", data: function(data){ return data.value; }, total: function(data){ return data['odata.count']; }, model: product }, pageSize: 50, serverPaging: true, serverFiltering: true, serverSorting: true }); -
获取数据:
productsDataSource.filter([{ field: "Id", operator: "eq", value: 5 }]); //这将发送一个http请求
productsDataSource.fetch(函数 (e) { tempDataStorage = e.items; //处理数据的更多逻辑; });
-
问题:
- 需要使用dataSource的fetch方法进行数据处理(widget初始化、数据绑定...等);
- 在 fetch 之前设置过滤器时避免发送两个 httprequest;
- 需要在运行时更改过滤条件。
【问题讨论】:
-
你有想过这个吗?
-
我认为不建议更改 _filter。 Telerik 的团队应该提供一种更好的方法来在绑定操作之前操作过滤器数组。 filter 方法会导致第二次服务器操作,这根本不好。目前,更改 _filter 似乎是唯一的解决方案,但是请注意,他们将来可以更改此变量的名称,然后您的应用程序可能会中断。
标签: kendo-ui datasource odata