cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to form filter parameter for a single property containing multiple dynamic values

former_member200679
Participant
0 Kudos

Hi all,

I have a select dialog, where user selects multiple products as shown below:

When "OK" button is pressed, i am going to pass two values in filter- one containing userId and another containing multiple product ID's. I am not sending a back-end call for this. Just need to show data on table based on selected products.

Please suggest how this can be achieved.

Thank you.

Regards,

Saurabh.

View Entire Topic
0 Kudos

Hi,

The logic behind this is as follows:

1.Bind the complete data with table

2.On "OK" press add all the filters like shown below:

var oFilter = [];

oFilter.push(new sap.ui.model.Filter("userid", sap.ui.model.FilterOperator.Contains, "userid123"));

oFilter.push(new sap.ui.model.Filter("productId", sap.ui.model.FilterOperator.Contains, "productId1"));

oFilter.push(new sap.ui.model.Filter("productId", sap.ui.model.FilterOperator.Contains, "productId2"));

var oBinding = sap.ui.getCore().btId("table-id").getBinding("items");

oBinding.filter(oFilter);

3.If multiple product ids are there then , you can use loop to push those into aFilter array.

Hope it will help 🙂

Best Regards,

Rajvardhan Thakare

former_member200679
Participant
0 Kudos

Hi Rajvardhan,

This is URL which i ran directly on browser:

http://netweavergateway.com:8031/sap/opu/odata/sap/ODATA_SRV/productSet?$filter=UserID eq '1234' and (ProductCode eq '1050' and

ProductCode eq '1060')

I want to implement the same in app using filter.

I am getting object object for multiple Product code.

0 Kudos

Hi Saurabh ,

You can consider following code:

Consider that your odata model is mapped into oModel variable then add following lines of code ,

oModel.read("/productSet?$filter=UserID eq '1234' and (ProductCode eq '1050' and

ProductCode eq '1060')",{

success: function(oData){

// you can create a breakpoint here and check oData variable , you will get the result set into oData variablr

},

error: function(oError){

}

});

Hope it will help,

Thanks,

Rajvardhan Thakare