过滤扩展的OData请求

Pie*_*ter 0 sapui5

我需要将参数传递给后端.我想为此使用$ filter.我下面的代码是不工作的,没有通过返回过滤器io_tech_request_context->get_filter( )->get_filter_select_options( )FiguresEntitySet的.

var aFilters = [ new sap.ui.model.Filter("TeamMembers/Figures/FILTERKEY", sap.ui.model.FilterOperator.EQ,   sFilterValue) ];

this.getView().bindElement({
    path: "/TeamDataSet('0')",
    parameters: {
     expand: 'TeamMembers/Figures'
    },
    filters: aFilters
});
Run Code Online (Sandbox Code Playgroud)

Bog*_*ann 5

元素绑定/ ContextBinding不支持该属性,filters因为您只绑定单个实体而不绑定集合.如果需要过滤Figures,则必须将它们绑定到聚合(例如,itemsList上),获取相应的ListBinding对象,然后.filter从那里调用.

这是一个类似的例子:https://embed.plnkr.co/AoIZI4/.看看处理程序onSearch.


如果某人实际上想要通过扩展结果过滤列表,则可以在过滤器路径中应用导航属性,然后通过绑定绑定对象的路径解析该过滤器路径.例如:

<List items="{
  path: 'myODataModel>/Products',
  parameters: {
    expand: 'ToSupplier'
  }
}"> 
Run Code Online (Sandbox Code Playgroud)

然后在Controller中,Products按其供应商国家筛选:

new Filter({
  path: "ToSupplier/Country",
  operator: "EQ",
  value1: "UK",
})
Run Code Online (Sandbox Code Playgroud)

(来自:https://embed.plnkr.co/wAlrHB/).

请注意,这只有当扩张并没有一个集合,但单一的对象(例如相关的供应商)的结果.从OData V4开始,通过查看相关集合进行过滤,可通过FilterOperator.All/.Any实现.