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'
}]
}"
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'
}]
}
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
}
]
}"
Working example: https://embed.plnkr.co/wAlrHB?show=view/Home.view.xml,preview
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 (and value2 if applicable)filters and and. <-- This is what we need.API reference: sap.ui.model.Filter
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.
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]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With