on 11-02-2016 1:05 PM
Hi All,
A am trying to get at complex filtering scenario to work on a master/detail app. Essentially it needs to combine a search filter(user can enter a text that is searched in a projectID or projectLongtext) with a status filter(which is controlled thru a toggle where the user selects either the active statuses or all projects).
So in a direct call I would like to have the filtering to be (Status1 or Status2..) && (Id = .. or longDescription = ..) and that works as intented.
http://..../projectMasterList?$skip=0&$top=5&$filter=((projectState
eq%20%27PEX%20Project.Analysis%27%20or%20projectState%20eq%20%27PEX%20Project.Development%27%20or%20projectState%20eq%20%27PEX%20Project.Roll%20Out%27)%20 AND %20(substringof(%27ROAD%27,projectID)%20or%20substringof(%27road%27,projectID)%20or%20substringof(%27Road%27,projectID)%20or%20substringof(%27ROAD%27,longDescription)%20or%20substringof(%27road%27,longDescription)%20or%20substringof(%27Road%27,longDescription)))
In UI5 I create the filters as follows:
oSearchFilter =
[new sap.ui.model.Filter
([
new sap.ui.model.Filter("projectID", sap.ui.model.FilterOperator.Contains, queryUpper, ''),
new sap.ui.model.Filter("projectID", sap.ui.model.FilterOperator.Contains, queryLower, ''),
new sap.ui.model.Filter("projectID", sap.ui.model.FilterOperator.Contains, queryUpLow, ''),
new sap.ui.model.Filter("longDescription", sap.ui.model.FilterOperator.Contains, queryUpper, ''),
new sap.ui.model.Filter("longDescription", sap.ui.model.FilterOperator.Contains, queryLower, ''),
new sap.ui.model.Filter("longDescription", sap.ui.model.FilterOperator.Contains, queryUpLow, '')
], false )
];
oActiveFilter =
[new sap.ui.model.Filter
([
new sap.ui.model.Filter("projectState", sap.ui.model.FilterOperator.EQ, 'PEX Project.Analysis', '' ),
new sap.ui.model.Filter("projectState", sap.ui.model.FilterOperator.EQ, 'PEX Project.Development', ''),
new sap.ui.model.Filter("projectState", sap.ui.model.FilterOperator.EQ, 'PEX Project.Roll Out', '')
], false )
];
Individually I can make the filtering work but I have problems combining them with an AND option. To combine them I do the following:
var oCombinedFilter = new sap.ui.model.Filter([oSearchFilter, oActiveFilter], true);
but the filter ends up entirely blank (binding. sFilterParams)
Any pointers would be appreciated,
MiB
I never tried two filters array into one, but i think you can try below
var oFilter1 = newsap.ui.model.Filter(oSearchFilter);
var oFilter2 = newsap.ui.model.Filter(oActiveFilter);
var oCombinedFilter =newsap.ui.model.Filter([oFilter1, oFilter2], true);
I am not sure but this may help.
Regards,
Akhilesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
try this,those two should not be array
oSearchFilter =newsap.ui.model.Filter([newsap.ui.model.Filter("projectID", sap.ui.model.FilterOperator.Contains, queryUpper, ''),newsap.ui.model.Filter("projectID", sap.ui.model.FilterOperator.Contains, queryLower, ''),newsap.ui.model.Filter("projectID", sap.ui.model.FilterOperator.Contains, queryUpLow, ''),newsap.ui.model.Filter("longDescription", sap.ui.model.FilterOperator.Contains, queryUpper, ''),newsap.ui.model.Filter("longDescription", sap.ui.model.FilterOperator.Contains, queryLower, ''),newsap.ui.model.Filter("longDescription", sap.ui.model.FilterOperator.Contains, queryUpLow, '')], false );
oActiveFilter =newsap.ui.model.Filter([newsap.ui.model.Filter("projectState", sap.ui.model.FilterOperator.EQ, 'PEX Project.Analysis', '' ),newsap.ui.model.Filter("projectState", sap.ui.model.FilterOperator.EQ, 'PEX Project.Development', ''),newsap.ui.model.Filter("projectState", sap.ui.model.FilterOperator.EQ, 'PEX Project.Roll Out', '')], false );
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
check what u have in the developer tool --->network tab
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
24 | |
11 | |
9 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.