on 08-06-2020 12:04 PM
I've got the question: List Item didn't display the data although showing the right number of items
Firstly, I set a model called "Courses" since there's not only one model for this view.
Next, I fetched the json data and set the property of "Courses" model. It worked well.
But no data displayed but item containers instead. No errors in the console.
Here's the controller:
onInit: function () {
this.getView().setModel(new JSONModel({}), "Courses");
var coursesList = new sap.ui.model.json.JSONModel();
coursesList.loadData("../model/CoursesList.json");
coursesList.attachRequestCompleted((function() {
this.getView().getModel("Courses").setProperty('/list', coursesList.getData());
console.log(coursesList.getData());
}).bind(this));
}
And the xml
<Page
id="master"
title="{i18n>findCourse}"
titleAlignment="Center"
backgroundDesign= "List"
icon="sap-icon://action"
class="sapUiStdPage">
<Button text="{i18n>adminCockpit}" press="onPress" />
<Button text="{i18n>cloudRefreshCalendar}" press="onPress" />
<SearchField width="95%" class="sapUiTinyMargin" />
<List items="{path: 'Courses>/list'}">
<items>
<StandardListItem title="{courseId}" type="Navigation" press=".onPressGoToMaster" />
</items>
</List>
</Page>
Here's the json:
[
{
"courseId": "ADM100",
"objectId": "123456",
"description": "This is a course ADM100"
},
{
"courseId": "ADM920",
"objectId": "123453",
"description": "This is a course ADM920"
},
{
"courseId": "S4LG1",
"objectId": "123452",
"description": "This is a course S4LG1"
},
{
"courseId": "S4MA1",
"objectId": "1234561",
"description": "This is a course S4MA1"
}
]
Hi,
Since you're using named model "Courses", model name is also required before property names as below.
{Courses>courseId}
Regards,
Mio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Victor,
It is explained in below document.
When you use multiple models, specify the model name within the binding path to address the correct model.
https://sapui5.hana.ondemand.com/#/topic/2888af49635949eca14fa326d04833b9
Regards,
Mio
Hi,
Looking at your issue, it is clear that the number of line items are coming based on the data. However, since nothing is displayed, this means that the key:"courseId" is not getting recognized during runtime.
To troubleshoot this, could you check at runtime what is the value that gets stored in your Courses model.
Best Regards,
Rohit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.