Skip to Content
-1

How to filter OData model at the backend?

May 17, 2017 at 08:15 PM

127

avatar image

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!

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

2 Answers

Jun Wu May 18, 2017 at 12:26 AM
-3

do some google please

Share
10 |10000 characters needed characters left characters exceeded
Mahesh kumar palavalli May 18, 2017 at 07:13 AM
0

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

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Thanks for the reply.

I got the point, I thought in my code the filter works at UI5 layer, but actually it's on OData layer which is what I want.

John

0

Yup.. Please close this Question if your query is solved.

Warm Regards,
Mahesh

0