cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic OData filter in sap.m.List (XML View)

cmetz
Participant
0 Kudos

Hey guys,

I am using a XML View and want to add a filter for the current date to control sap.m.List. In this case I hard coded the datetime and its working fine, but I want to retrieve the date dynamically.

<List

  id="idMasterList"

  mode="SingleSelectMaster"

  select="handleListSelect"

  items="{

       path: 'ModelKundenInfos>/DeliveryHeaderSet',

       parameters: {expand:'ToCustomer,LineItems'},

       filters: [{path : 'Lfdat',operator : 'EQ',value1:'2014-07-03T00:00:00'}]

  }" >

<ObjectListItem

  id="idObjectListItem"

  type="Inactive"

  press="handleListItemPress"

....

</List>

Thanks and regards

Chris

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I am not sure if you still have the problem.

I have similar requirement and I am able to achieve it by following method.

I think at design time in XML view, you cannot give dynamic parameter. You have to set item binding in view controller. Please see following code here I am reading Country list base on user's browser language. Similarly you can update the code to create filter object dynamically for Date

                              var oItems = new sap.ui.core.ListItem({

                                                        key : "{CountryKey}",

                                            text : "{CountryName}",

                                        });

                             

                              var oCustomerCountry = sap.ui.getCore().byId("idCustomerCountry");

                             

                              var oSorter= {

                                                path: 'CountryName',

                                                descending: false,

                                                group: true

                                              };

                             

                                          var oFilters = new sap.ui.model.Filter("Language", sap.ui.model.FilterOperator.EQ,                                                                                                     navigator.language.substr(0,1).toUpperCase());  // Dynamic parameter

                               oCustomerCountry.bindItems("/CountryCollection", oItems, oSorter, oFilters);

cmetz
Participant
0 Kudos

Hi Vikram,

yeah that's exactly how I solved it as well. But actually I though there is direct way at design time.

If u do the binding with a list, I had to define the list template again. This is how I solved it:

this.oObjectListItem2 = new sap.ui.xmlfragment("sap.ui.demo.myFiori.MeineRouteApp.view.fragment.DeliveryListItemTemplate", this);

this.oList.bindAggregation("items", {

  path: "ModelKundenInfos>/DeliveryHeaderSet",

  template: this.oObjectListItem2,

  filters: filters,

  parameters: {expand:'ToCustomer,LineItems,ToNote,ToDisponent'}

});

Regards

Chris

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Did you find the solution? I also have same requirement.

Regards,

Vikram