on 11-10-2015 10:42 AM
Hi all,
I want to implement a search in SAPUI5. There you can use the asterix () like in SAP.</p><p>So for example, if you want don't know the exact string you could write "HansHuber". So everything which starts with "Hans" and ends with "Huber" should be found.
With the filters in SAPUI5 there is the open with startsWith, endsWith - so this is no problem. But the problem is, that it does a OR relation and not a AND relation.
Here is the parameter string I get for the above example:
((startswith(BeCode,'HANS') or endswith(BeCode,'HUBER')))
As you can see, there is an OR but I need an AND. Could it be, that is automatically an OR because I want to filter two times on the same attribute (BeCode)? By default, SAPUI5 does the filter relation with AND - if you want to OR you have explicit set a flag.
Somebody any idea?
Thank you in advance,
Bastian
Hi Bastian,
There is an argument available in sap.ui.model.filter as 'and'.
API (Check the last argument) - JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.model.Filter
You have to say something like this:
new sap.ui.model.Filter({
filters: [arrayOfFilters],
and: true //change to false to set it 'or'
});
Regards,
Sai Vellanki.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
thanks. Found it myself in the same second you wrote it
Pushed all filters into an array:
aFilters.push(oFilter);
and afterwards created a new filter with the set of the above filters and the boolean value.
var oFilters1 = new sap.ui.model.Filter(aFilters, true);
Now everything is fine
Thanks,
Bastian
Hi Bastian,
When building your filter, you can set it to use AND instead of OR as a conjunction. Please refer to the API:
https://openui5.hana.ondemand.com/docs/api/symbols/sap.ui.model.Filter.html
This line is interesting for you:
{boolean} | oFilterInfo.and | indicates whether an "and" logical conjunction is applied on the filters. If it's set to false, an "or" conjunction is applied |
Hope this helps!
Regards,
Szilamér
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.