cancel
Showing results for 
Search instead for 
Did you mean: 

Filtering of a List

Former Member
0 Kudos

Hi,

I have a view and on a click of a icon, it displays a search popup window. Upon searching, we display the results in a list in the same popup. I need to do a filtering on this list.

The UI for the popup is defined in Dialog.Fragment.xml file. The list is also defined in the dialog fragment.

I wrote the below statements on the action handler of filtering in S2 controller.

var list = this.getView().byId("idList");
  var binding = list.getBinding("items");
  binding.filter(aFilters, "Application");

When I debug the code, list is coming as undefined.

How to retreive the id of the list from a dialog fragment.

I have attached the relative files for reference.

Regards

V

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member182372
Active Contributor
0 Kudos

this._oDialog = sap.ui.xmlfragment("MyDialog", "cus.sd.priceavailability.check.ZSD_PRAV_MON.view.Dialog", this);

var list = this.getView().byId("MyDialog--idList");

Former Member
0 Kudos

My code looks like below now.

onFilter: function(oEvent) {

     // add filter for search

    var aFilters = [];

    var sQuery = oEvent.getSource().getValue();

    if (sQuery && sQuery.length > 0) {

      var filter = new sap.ui.model.Filter("Mcod1", sap.ui.model.FilterOperator.Contains, sQuery);

      aFilters.push(filter);

    }

    // update list binding

    this._oDialog = sap.ui.xmlfragment("MyDialog", "cus.sd.priceavailability.check.ZSD_PRAV_MON.view.Dialog", this);

    var list = this.getView().byId("MyDialog--master1List");

    var binding = list.getBinding("MyDialog--items");

    binding.filter(aFilters, "Application");

 

},

I am getting the below errors in console

webidetestingonsxal-p808141trial.dispatcher.hanatrial.ondemand.com/view/S2Custom.controller.js:180 Uncaught TypeError: Cannot read property 'getBinding' of undefined

sap-ui-core.js:80 2015-04-23 14:39:38 [index.html] adding element with duplicate id 'MyDialog--salesOffice' -  y @ sap-ui-core.js:80

sap-ui-core.js:135 Uncaught Error: Error: adding element with duplicate id 'MyDialog--salesOffice'

sap-ui-core.js:80 2015-04-23 14:39:38 [index.html] adding element with duplicate id 'MyDialog--salesGroup' -  y @ sap-ui-core.js:80

sap-ui-core.js:135 Uncaught Error: Error: adding element with duplicate id 'MyDialog--salesGroup'

sap-ui-core.js:80 2015-04-23 14:39:39 [index.html] adding element with duplicate id 'MyDialog--salesOffice' -  y @ sap-ui-core.js:80

sap-ui-core.js:135 Uncaught Error: Error: adding element with duplicate id 'MyDialog--salesOffice'

former_member182372
Active Contributor
0 Kudos

sorry, my bad

sap.ui.getCore().byId


not


this.getView().byId


and


list.getBinding("items");


not


list.getBinding("MyDialog--items");

Former Member
0 Kudos

I am getting the below error now

Uncaught TypeError: Cannot read property 'filter' of undefined

Former Member
0 Kudos

Now I am getting the below error

Uncaught TypeError: Cannot read property 'filter' of undefined

former_member182372
Active Contributor
0 Kudos

either do

<List id="master1List" items="{/PATH_TO_DATA}"


or instead of filter call

list.bindIAggregation("items",

{

path : "/Path_TO_DATA",

template : new StandardListItem(...SAME AS IN XML),

filters : aFilters

)



Former Member
0 Kudos

I wrote the below code

onFilter: function(oEvent) {

     // add filter for search

    var aFilters = [];

    var sQuery = oEvent.getSource().getValue();

    if (sQuery && sQuery.length > 0) {

      var filter = new sap.ui.model.Filter("Mcod1", sap.ui.model.FilterOperator.Contains, sQuery);

      aFilters.push(filter);

    }

    // update list binding

  

    this._oDialog = sap.ui.xmlfragment("MyDialog", "cus.sd.priceavailability.check.ZSD_PRAV_MON.view.Dialog", this);

    var list = sap.ui.getCore().byId("MyDialog--master1List");

  list.bindAggregation("items", {path:pathStr

         ,template : new sap.m.ObjectListItem(

                {title:"{Mcod1} ",

                  number : "", type: "Active",

                  attributes: [new sap.m.ObjectAttribute({

                        text : "(#{Kunn2}, {Vkgrp}, {Vkbur})"

                  }),

                  new sap.m.ObjectAttribute({

                        text : "#{Stras}, {Mcod3}, {Regio}-{Pstlz}"

                  })],

                  filters:aFilters

                }

            })

     });

But displaying the below errors in console

2015-04-23 17:42:12 [index.html] adding element with duplicate id 'MyDialog--salesOffice'

Uncaught Error: Error: adding element with duplicate id 'MyDialog--salesOffice'

2015-04-23 17:42:12 [index.html] adding element with duplicate id 'MyDialog--salesGroup'

Uncaught Error: Error: adding element with duplicate id 'MyDialog--salesGroup'

former_member182372
Active Contributor
0 Kudos

move


this._oDialog = sap.ui.xmlfragment("MyDialog", "cus.sd.priceavailability.check.ZSD_PRAV_MON.view.Dialog", this);

this.template = new sap.m.ObjectListItem(

{

  title : "{Mcod1}",

  number : "",

  type: "Active",

  attributes: [

  new sap.m.ObjectAttribute({text : "(#{Kunn2}, {Vkgrp}, {Vkbur})"}),

  new sap.m.ObjectAttribute({text : "#{Stras}, {Mcod3}, {Regio}-{Pstlz}"})

  ]

});

to onInit

and do

list.bindAggregation("items",

{

  path : pathStr,

  filters : aFilters

  template : this.template

});

in onFilter