2024 Jun 03 4:05 PM - edited 2024 Jun 03 4:40 PM
Hi experts,
I am new to SAPUI5 and still learning.
I have this problem where the skills and proficiency values should come from the entities via a global JSON Model. I have tried everything and searched everywhere but it is not working.
I decided to put my global json model in COMPONENT.JS
sap.ui.define ([
"sap/ui/core/UIComponent"
"sap/ui/model/json/JSONModel"
], function (UIComponent, JSONModel) {
return UI.Component.extend("namespace",{
//define the global JSON model
var oModel = new JSONModel();
this.setModel(oModel, "globalModel");
//Load data
var oData = {
skills: [
{id: 1, skill: "JavaScript"},
{id: 2, skill: "SAPUI5:}
]
proficiencies: [
{id: 1, level: "Beginner"},
{id: 2, level: "Expert"}
]
};
oModel.setData(oData)
}
});
In my mainview.xml
<VBox>
<ComboBox items="{path: 'globalModel>/skills'}"
placeholder="Select Skill">
<core:Item key="{globalModel>id}" text="{globalName>skill}"/>
</ComboBox>
<ComboBox items="{path: 'globalModel>/proficiencies'}"
placeholder="Select Proficiency">
<core:Item kety="{globalModel>id}" text="{globalName>level}"/>
</ComboBox>
In my controller.js
return Controller.extend("namespace"){
onInit: function (){
//Access Global
var oModel = this.getOwnerComponent().getModel("globalModel);
console.log(oModel.getData());
}
}
Appreciate you help!
Request clarification before answering.
sap.ui.define ([
"sap/ui/core/UIComponent"
"sap/ui/model/json/JSONModel"
], function (UIComponent, JSONModel) {
return UI.Component.extend("namespace",{
//define the global JSON model
var oModel = new JSONModel();
//Load data
var oData = {
skills: [
{id: 1, skill: "JavaScript"},
{id: 2, skill: "SAPUI5:}
]
proficiencies: [
{id: 1, level: "Beginner"},
{id: 2, level: "Expert"}
]
};
oModel.setData(oData);
this.setModel(oModel,"globalModel")
}
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 10 | |
| 7 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.