Skip to Content
-1

How to filter OData model at the backend?

Hi Gurus

I am quite new on UI5, I am developing a page to show a list using OData & XML View.

It works fine if I retrieve the whole data set and do filtering at the frontend.

But, I want to do filtering at the backend before the data passing to the browser to save bandwidth, how can I do that?

Below is the code I am using now:

Create and bind data model:

var sInvStockUrl = "/sap/opu/odata/SAP/Z_XXXX_SRV/";
//create model
var oStockModel = new ODataModel(sInvStockUrl,"stockModel");
//set model
 this.getView().byId("stockList").setModel(oStockModel,"stockModel");

Filtering when I click a button:

//create filters
var aFilter = [];
aFilter.push(new Filter("Field1", FilterOperator.EQ, "AAA"));
aFilter.push(new Filter("Field2", FilterOperator.EQ, "BBB"));
//apply filters
var oTable = this.getView().byId("stockList");
oTable.getBinding("items").filter(aFilter);

Thanks in advance!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • May 18, 2017 at 12:26 AM
    -3

    do some google please

    Add comment
    10|10000 characters needed characters exceeded

  • May 18, 2017 at 07:13 AM

    what is the issue you are facing now?, ur code seems to be fine... do u want to know what the code to be written in odata layer?

    If yes, you need to use the filter the data in getentityset method(you will find an importing filters parameter)

    Best Regards,

    Mahesh

    Add comment
    10|10000 characters needed characters exceeded