0

I am reading two parameters from URL.

 var spayid = jQuery.sap.getUriParameters().get("payid"); 
 var spaydt = jQuery.sap.getUriParameters().get("paydt");

Now I have to pass these two filter options in my odata service.

this.getView().setModel(new ODataModel("proxy/http/FIORI-DEV.abc.com:8000/sap/opu/odata/sap/Z_OD_SRV/?sap-client=100", {    
json : true,
useBatch : false})

Entity Name= PDetailSet Field name for spayid is Laufid and spaydt is Laufdt.

Please help how to pass filters in odata service.

NB: I have also add the filters in the following way.

var filter1= new sap.ui.model.Filter(
    { path: "Laufi", operator: sap.ui.model.FilterOperator.EQ, value1: spayid });
var filter2= new sap.ui.model.Filter(
    { path: "Laufd", operator: sap.ui.model.FilterOperator.EQ, value1: spaydt });
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Ahmed
  • 33
  • 6
  • I have also add the filters in the following way. var filter1= new sap.ui.model.Filter({ path: "Laufi", operator: sap.ui.model.FilterOperator.EQ, value1: spayid }); var filter2= new sap.ui.model.Filter({ path: "Laufd", operator: sap.ui.model.FilterOperator.EQ, value1: spaydt }); – Ahmed Jul 15 '20 at 10:06
  • Does this answer your question? [Problem in adding multi filter to odata service](https://stackoverflow.com/questions/61203299/problem-in-adding-multi-filter-to-odata-service) – Marc Jul 15 '20 at 10:25
  • I want to pass filter parameters on ODATA service so that only results which are required comes in the list. – Ahmed Jul 15 '20 at 10:37
  • Does this answer your question? [Filter with "OR" And "AND" Conditions on Multiple Fields](https://stackoverflow.com/questions/42433200/filter-with-or-and-and-conditions-on-multiple-fields) – Boghyon Hoffmann Jul 15 '20 at 15:13
  • This question seems to be same as [one of your previous questions](https://stackoverflow.com/q/62949276/5846045). Is it still about the master detail problem? If then, `Filter` is a wrong approach. Instead of asking multiple questions about the same problem, consider following the official _[learning path](https://openui5nightly.hana.ondemand.com/topic/8b49fc198bf04b2d9800fc37fecbb218)_ from the documentation first. – Boghyon Hoffmann Jul 21 '20 at 18:08

1 Answers1

2

A model itself can not be filtered, but a binding can. So if you bind your dataset to a table i.e. you could filter that binding with your filters, as described in your comments.

That would look like this:

oTable.getBinding("rows").filter(filter1);

To combine your two filters, you can use another filter, which has the advantage that you can decide wheter to use "and" or "or". You can see a detailed example for that in the documentation.

Jan W
  • 904
  • 2
  • 7
  • 14