Skip to Content

List Item didn't display the data although showing the right number of items

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"
    }
]

1.png (8.2 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Aug 06, 2020 at 12:11 PM

    Hi,

    Since you're using named model "Courses", model name is also required before property names as below.

    {Courses>courseId}

    Regards,

    Mio

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 06, 2020 at 11:42 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.