Skip to Content

Display Json data in table

Hello

I am trying to display json data in table but am getting blank table everytime. Here is my code:

<Table id="Table_Id"

items="{oModel/Hier}"

noDataText="No Data Created Yet" >

<columns>

<Column>

<Text text="ID" />

</Column>

<Column >

<Text text="Name" />

</Column>

</columns>

<items>

<ColumnListItem>

<cells>

<Text text="{oModel>ID}" />

<Text text="{oModel>NAME}" />

</cells>

</ColumnListItem>

</items>

</Table>

In controller

var oModel = new sap.ui.model.json.JSONModel({

Hier: [{

ID: "KLJNB",

NAME: "AJY",

},

{

ID: "OLJNB",

NAME: "OAJY",

}

]

});

sap.ui.getCore().setModel(oModel,"omodel");

console.log(oModel);

},

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Jul 27, 2016 at 04:57 AM

    Hi Justin,

    Also one more thing to add to Deepak's solution, your 'items' binding path should be:

    items="{oModel>/Hier}"

    Regards,

    Sai.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 27, 2016 at 04:34 AM

    Hi,

    Check for difference in the name of model.

    Change the name of model when setting it to oModel instead of omodel in controller.

    i.e. sap.ui.getCore().setModel(oModel, "oModel").

    Thanks

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 27, 2016 at 05:50 PM

    Hi Justin,

    bind table with "{/Hier}" and for each column just give "{ID}" and "{NAME}"

    When u bind table with "{/Hier}" each object from this array is automatically binded with each rows... so in rows just specify property name as {ID} .. try this out

    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.