XML 中的多个过滤器

编程入门 行业动态 更新时间:2024-10-19 12:43:43
本文介绍了XML 中的多个过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

所以我有一个列表,但如果它的 '05' 或 '01' 不显示在列表中,我想过滤掉类型.以下代码适用于 '05' 但不适用于 '01'.我将如何编写它以添加另一个值?

So I have a list but I want to filter out the type if its '05' or '01' to not display in the list. The following code work fine for '05' but not '01'. How would I write it to add another value?

items="{ path: 'Entries', filters: [{ path: 'Type', operator : 'NE', value1 : '05', value2: '01' }] }"

我尝试了这个,我认为这是合乎逻辑的方式,但它随后开始显示 05 和 01.所以我认为这是使用 OR 过滤器而不是过滤器 AND 过滤器组合.

I tried this which I would assume is the logical way, but it then started displaying both 05 and 01. So I assume this is using an OR filter rather than filter AND filter combined.

items="{ path:'Entries', filters: [{ path: 'Type', operator: 'NE', value1: '05' }, { path: 'Type', operator: 'NE', value1: '01' }] }

推荐答案

以下是 XML 视图中的语法:

Here is the syntax in XML view:

items="{ path: '/Products', filters: [ { filters: [ { path: 'ProductName', operator: 'StartsWith', value1: 'Sir ' }, { path: 'Discontinued', operator: 'EQ', value1: false }, ], and: true } ] }"

工作示例:embed.plnkr.co/wAlrHB?show=view/Home.view.xml,预览

参数 filters 等待过滤器信息对象的数组.过滤器信息对象受限于以下属性组合:

The parameter filters awaits an array of filter info objects. A filter info object is constrained in the following combinations of properties:

  • path、operator、value1(和 value2,如果适用)
  • 或者 filters 和 and.<-- 这就是我们需要的.
  • path, operator, value1 (and value2 if applicable)
  • Or filters and and. <-- This is what we need.

API 参考:sap.ui.model.Filter

API reference: sap.ui.model.Filter

您的第二种方法不起作用的原因是,两个过滤器都指向导致 OR 逻辑的同一路径 ('Type').

The reason, why your second approach didn't work, is because both filters were pointing to the same path ('Type') which results in OR logic.

应用于单个表列的所有过滤器都是 OR 运算,而不同表列的过滤器是 AND 运算.请使用过滤器的自动分组(如果适用)或使用显式 AND/OR 过滤器,不支持两者的混合.[来源]

All filters applied to a single table column are ORed, while filters on different table columns are ANDed. Please either use the automatic grouping of filters (where applicable) or use explicit AND/OR filters, a mixture of both is not supported. [source]

更多推荐

XML 中的多个过滤器

本文发布于:2023-11-22 13:45:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1617661.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   过滤器   XML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!