cancel
Showing results for 
Search instead for 
Did you mean: 

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

0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

MioYasutake
Active Contributor

Hi,

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

{Courses>courseId}

Regards,

Mio

0 Kudos

Hi Mio,

Glad to hear your reply. It works. But could u pls tell me the reason why the syntax should be like this. Never saw this pattern before. Do u have any idea?

Victor

MioYasutake
Active Contributor

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

Answers (1)

Answers (1)

rohit_singhal
Active Contributor
0 Kudos

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

0 Kudos

Hi Rohit,

Thanks for replying. It seems like it works after doing some updates like this:

{Courses>courseId}

Victor