Hi,
I have a problem with the databinding for a sap.m Table. The following example works fine as expected. The Model is set as root model, I used the JSON file from the Fiori example:
<core:Viewxmlns:core="sap.ui.core"xmlns:mvc="sap.ui.core.mvc"xmlns="sap.m"
controllerName="table.MainView"xmlns:html="http://www.w3.org/1999/xhtml">
<Pagetitle="Title">
<content>
<Table
headerText="Test Table"
items="{/SalesOrderCollection}">
<columns>
<Column>
<header><Labeltext="Sales Order Id"/></header>
</Column>
<Column>
<header><Labeltext="Status"/></header>
</Column>
<Column>
<header><Labeltext="Created by"/></header>
</Column>
</columns>
<ColumnListItem
type="Navigation"
press="handleLineItemPress">
<cells>
<ObjectIdentifier
title="{SoId}"/>
<Text
text="{Status}"/>
<Text
text="{CreatedByBp}"/>
</cells>
</ColumnListItem>
</Table>
</content>
</Page>
</core:View>
This is how I set the Model
onInit: function() {
// Using a local model for offline development
var oModel = new sap.ui.model.json.JSONModel("mock.json");
this.getView().setModel(oModel);
},
And here the begin of the Model:
{
"SalesOrderCollection": [
{
"SoId": "300000097",
"ApprovalStatus": "",
"Status": "Initial",
"ConfirmationStatus": "",
"BillingStatus": "Initial",
"OrderingStatus": "",
"OrderingStatusDesc": "Initial",
"LifecycleStatus": "P",
"LifecycleStatusDesc": "",
"GrossAmount": "13224.47",
"BuyerName": "11113.00",
"TaxAmount": "2111.47",
...
And now the problem. I want to set the model not as root, so I changed the following line (line 4)
onInit: function() {
// Using a local model for offline development
var oModel = new sap.ui.model.json.JSONModel("mock.json");
this.getView().setModel(oModel, "Order");
},
In the XML View I changed the line 7
<core:Viewxmlns:core="sap.ui.core"xmlns:mvc="sap.ui.core.mvc"xmlns="sap.m"
controllerName="table.MainView"xmlns:html="http://www.w3.org/1999/xhtml">
<Pagetitle="Title">
<content>
<Table
headerText="Test Table"
items="{Order>/SalesOrderCollection}">
<columns>
<Column>
<header><Labeltext="Sales Order Id"/></header>
</Column>
<Column>
<header><Labeltext="Status"/></header>
</Column>
<Column>
<header><Labeltext="Created by"/></header>
</Column>
</columns>
<ColumnListItem
type="Navigation"
press="handleLineItemPress">
<cells>
<ObjectIdentifier
title="{SoId}"/>
<Text
text="{Status}"/>
<Text
text="{CreatedByBp}"/>
</cells>
</ColumnListItem>
</Table>
</content>
</Page>
</core:View>
The result is an empty table, the rows are shown but the columns are empty. This means for me, that the table can be found, but the data in the table not.
What is my mistake?
Thanks for help and sorry for so much code.
Best regards
Renald
PS Why do I have perfekt syntax highlighting in the edit mode but not if I show this threat?