KendoUI数据源 - 从筛选器属性的OData查询字符串 [英] KendoUI DataSource - OData querystring from filter attribute

查看:1075
本文介绍了KendoUI数据源 - 从筛选器属性的OData查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在当前项目在这个博客描述我想用角的$ HTTP服务,使HTTP请求在我的剑道数据源,因为我使用响应拦截器:

In a current project I would like to use the $http service of angular to make HTTP requests in my Kendo Data Sources, because I am using a response interceptor as described in this blog:

http://www.espeo.pl/2012/ 2月26日/认证在angularjs应用

我在我的应用程序中使用KendoUI网格显示数据,这是我在从服务器JSON格式得到。由于某些原因,ODATA查询被切断,如果我指定在运送-object只有URL的功能被发送到服务器(example.com/odata/Foo),而不是完整的查询(example.com / ODATA /富?$ =过滤barId为lt 100)。

I am using a KendoUI Grid in my application to display data, which I get in JSON format from the server. For some reason the odata query is cut off, if I specify a function in the "transport"-object and only the URL is sent to the server (example.com/odata/Foo), rather than the full query (example.com/odata/foo?$filter=barId lt 100).

设置我的剑道数据源是这样的:

I set up my Kendo DataSource like this:

$scope.foo = new kendo.data.DataSource({
        type: "odata",
        pageSize: 25,
        serverPaging: true,
        serverFiltering: true,
        serverSorting: true,
        transport: {
            read: function (options) {
                $http({
                    url: '/odata/foo',
                    method: 'GET',
                    params: options.data
                })
                .success(function (result) {
                    options.success(result);
                });
            },
            parameterMap: function (options, type) {
                return kendo.data.transports["odata"].parameterMap(options, type);
            }
        }

HTTP请求使用,我并没有与该问题的角度做工精细$ http服务。这个问题似乎是我无法得到查询部分(URL?$过滤器= [过滤前pression])从我的剑道数据过滤器对象资源。我尝试使用parameterMap的选项,但没有得到期望的结果,无论是。

HTTP requests using the $http service of angular work fine, I'm not having problems with that. The problem seems that I am unable to get the query part (URL?$filter=[filter expression]) from the "filter" object in my kendo data source. I tried using the parameterMap option, but that did not give the desired results, either.

推荐答案

而不是在参数映射功能,这样做的:

Instead of doing this in the parameter map function:

kendo.data.transports["odata"].parameterMap(options, type);

其中似乎并不时在传送的读取属性被映射到一个函数被调用。您可以在transport.read函数调用这样的:

which doesn't seem to be called when the read property on the transport is mapped to a function. You can call this in the transport.read function:

transport: {
  read: function (options) {
      var odataParams = kendo.data.transports["odata"].parameterMap(options.data, "read");
      $http({
        url: '/odata/foo',
        method: 'GET',
        params: odataParams
      })
      .success(function (result) {
        options.success(result);
      });
    }
  }

这篇关于KendoUI数据源 - 从筛选器属性的OData查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆