on 2016 Aug 09 6:51 AM
Hi Experts,
I have created a custom UI5 application using HCP WebIDE. I create models in manifest.json. Models are getting executed and I am able to see the data in controls.
My question is how can I access named models in my controller ? For example : In below screen shot I have defined a model called "countrySet". I want to access this named model in controller of my view.
Do I need to set Model/SRV in component.js ? If yes, how to do it ?
Thanks and Regards
Abhijeet
if you are not at controller of your 'rootView' of the UIComponent,
this.getOwnerComponent().getModel("countrySet") // 'this' being the controller of the view
else
this.getView().getModel("countrySet") would suffice
// eg. view=>App.view.xml and App is the 'rootview' specified in manifest.json
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi D.Chia,
Thanks for you quick reply.
this.getOwnerComponent().getModel("countrySet") // Working fine I am able to retrieve data.
this.getView().getModel("countrySet") // Undefined .. I think I need to execute this in APP view controller or Component.js.
I have one more question related to it. How do you access default model / Service defined in manifest.json.
Thanks and regards,
Abhijeet
the default model is also known as the "unnamed" model.
thus you just need to call the getModel method without passing any parameter/name
this.getOwnerComponent().getModel()
view.xml
items="{model: 'solicitation', path: '/solicitation'}"
item table
<Text text="{path: 'solicitation>solicitation_id', formatter: '.formatter.numberInt'}"/>
controller.js
this.getOwnerComponent().getModel("solicitation")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
64 | |
10 | |
8 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.