Skip to Content
0

UI5 complex filtering on masterlist

Nov 02, 2016 at 01:05 PM

71

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
avatar image
Former Member Nov 02, 2016 at 04:34 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Jun Wu Nov 02, 2016 at 03:30 PM
0

check what u have in the developer tool --->network tab

Share
10 |10000 characters needed characters left characters exceeded
Jun Wu Nov 02, 2016 at 06:02 PM
0

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 );


Share
10 |10000 characters needed characters left characters exceeded