Skip to Content
0
Former Member
Jul 15, 2016 at 06:13 PM

Pass Filter option to Odata Request

2309 Views

Hello UI5 gurus,

I have one custom Odata service in SAP system and can call it using the link directly in browser:
http://<host>:<port>/sap/opu/odata/sap/ZCUSDATA/CustomerDataSet?$filter=CountryKey eq 'US'

My intend is to develop UI5 application to call the same link and just change CountryKey value if needed.

My Controller coding at the moment:

sap.ui.define([
  "sap/ui/core/mvc/Controller"
], function(Controller) {
  "use strict";
  return Controller.extend("testodata4.controller.View1", {
  onInit: function() {


  var sServiceUrl = "/sap/opu/odata/sap/ZCUSDATA/";
  var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, true);
  sap.ui.getCore().setModel(oModel);
  }
  });

$filter= statement is important in the link, doesn't work without it.

Could you please share your knowledge and advise:

1. How I can implement Controller to get the link with "CustomerDataSet?$filter=CountryKey eq 'US'" ?

2. Is it possible to post filter values storing in the table? Not important for this case, just for future.

If anyone has any ideas I'd love to hear from you. I'm sure I'm missing something really small.

Thanks.

Regards,

Aliaks

Attachments