cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5: Applying Filters on the Master Screen

chandansb
Active Contributor
0 Kudos

Hello Experts,

I have created an app which will fetches Accounts using ODATA. My requirement is to fetch ONLY the Active Accounts. I understand this is to be done using ?filter option, but unable to use this.

Can someone please help me understand how would I display only Active Accounts? Right now I am using only "{/AccountCollection}" on Master.xml,

<Table id="catalogTable" class="navTableControlLayout" items="{/AccountCollection}" growing="true" growingScrollToLoad="true">

What modifications will I have to do here?

Thanks in Advance.

Regards,

Chandan

Accepted Solutions (1)

Accepted Solutions (1)

kedarT
Active Contributor
0 Kudos

Hi Chandan,

Not sure how it can be achieved in HTML but if it is JS view, below code will do the filtering:

oTable = sap.ui.getCore().byId("catalogTable");

oItem = sap.ui.getCore().byId("items");

oFilter = new sap.ui.model.Filter("Account", "EQ", value);

oTable.bindAggregation("items","/AccountCollection",oItems,null,oFilter1);

Hope this could be pointer.

chandansb
Active Contributor
0 Kudos

Thanks a lot Kedar, This has worked for me.

Cheers,

Chandan

chandansb
Active Contributor
0 Kudos

How would I apply multiple filters, say Active and Unassgined Accounts?

("StatusCode", "EQ", 2) ("OwnerID", "NE", '')

Thanks,

Chandan

kedarT
Active Contributor
0 Kudos

oFilter1 = new sap.ui.model.Filter("StatusCode", "EQ", 2);

oFilter2 = new sap.ui.model.Filter("OwnerID", "NE", " ");

oTable.bindAggregation("items","/AccountCollection",oItems,null,[oFilter1,oFilter2]);

Answers (1)

Answers (1)

saivellanki
Active Contributor
0 Kudos

Hi Chandan,

Try this -



  <Table

    items="{

      path: '/AccountCollection',

      filter: {

        path: 'ActiveAccount',               //Provide the field name that you wanted to filter

        operator: 'EQ',

        value1: value                              //Pass the field value that you wanted to filter

      }" >

Regards,

Sai Vellanki.