Quantcast
Channel: SCN : All Content - SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 6178

Controller - Cannot get reference by Id from View

$
0
0

Dear UI5 Friends,

 

I'm having a hard time getting the reference to an element in my view from its controller. I tried several combinations like using createId, giving the HTML5 name of the element etc, but nothing seems to work. Another strange problem I noticed in the process is, this.getView() does not give the reference to the view in the controller all the time. It works in onInit, but does not work in the search handler of a SearchField. My coding is as follows:

 

In the View

-----------------------------------

           

                var searchField100 = new sap.m.SearchField({

                                            id: this.createId("searchField100"), //Tried it also without createId

                                                          placeholder: "Search ...",

                                            search: oController.search,

                                            tooltip: "Search for Products",

                                            layoutData: new sap.m.FlexItemData({growFactor: 1})

                                                        });

 

                  this.page = new sap.m.Page({

                                        backgroundDesign: sap.m.PageBackgroundDesign.List,

                                        title: "Choose Country",

                                        showNavButton: true,

                                        navButtonTap: [oController.back, oController],

                                        icon: "{img>/icon/ui5}" ,

                                        subHeader: new sap.m.Bar({

                   enableFlexBox: true,

                   contentMiddle: searchField100

                                        })

                              });

 

In Controller

-----------------------------------

var searchField100= sap.ui.getCore().byId("searchField100");

 

 

Could you please help?

 

Thanks,

Sandeep


Viewing all articles
Browse latest Browse all 6178

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>