cancel
Showing results for 
Search instead for 
Did you mean: 

How to bind JSON to UI5 Table (sap.ui.table)

kulu
Explorer
0 Kudos

Hello, I want to bind some JSON to a Table (sap.ui.table). However the binding is not working. Here is my code:

After the API call, the content is bound to the table like this:

this.getView().byId("elementsItemsTable").setModel(new JSONModel(), "elementItemsTableModel");
this.getView().byId("elementsItemsTable").getModel("elementItemsTableModel").setData(elementItems.data);

The table in xml:

<table:Table id="elementsItemsTable" visible="false"
rows="{ path: 'elementItemsTableModel>/' }">
<table:extension>
<OverflowToolbar style="Clear">
<Title id="title" text="Longest running elements"/>
<SearchField
placeholder="Filter"
value="{ui>/globalFilter}"
search="filterGlobally"
width="15rem"/>
</OverflowToolbar>
</table:extension>
<table:columns>
<table:Column filterProperty="Phasename"
showFilterMenuEntry="true">
<Label text="Product Name" />
<table:template>
<Text text="{/name}" wrapping="false" />
</table:template>
</table:Column>
<table:Column>
<Text text="Duration"/>
</table:Column>
</table:columns>
</table:Table>

However no content is show. There are 10 rows displayed but not the "name" in the first column. I guess somewhere is missing something small.

Thanks

View Entire Topic
junwu
Active Contributor
make sure it is pointing to the array rows="{ path: 'elementItemsTableModel>/' }">

then, here you need the model name in the binding.
<Text text="{elementItemsTableModel>name}" wrapping="false" />