为什么我的过滤器在 v2.ODataModel “read"中不起作用? [英] Why my filter is not working in v2.ODataModel "read"?

查看:13
本文介绍了为什么我的过滤器在 v2.ODataModel “read"中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 OData 模型读取数据.但它不起作用.检查下面的代码:

I am using the OData model to read data. But it doesn't work. Check the code below:

getGuid: function(pernr) {
  var self = this;
  var url = "/PersonalDetailSet?$filter=Pernr eq '00000001'";
  self.setBusy(true);
  this.oModel.read(url, {
    success: function(res) {
      // ...
    },
    error: function() {
      // ...
    }
  });
}

我不知道为什么 url 中的过滤器现在不起作用?

I don't know why the filter in url is not working now?

推荐答案

  1. 首先检查您的 OData 服务是否支持 $filter 查询.
  2. 正确使用 read 方法:
myV2ODataModel.read("/PersonalDetailSet"/* No $filter queries here! */, {
  filters: [ // <-- Should be an array, not a Filter instance!
    new Filter({ // required from "sap/ui/model/Filter"
      path: "myField",
      operator: FilterOperator.EQ, // required from "sap/ui/model/FilterOperator"
      value1: "..."
    })
  ],
  // ...
});

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