on 11-06-2014 6:36 PM
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:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
controllerName="table.MainView" xmlns:html="http://www.w3.org/1999/xhtml">
<Page title="Title">
<content>
<Table
headerText="Test Table"
items="{/SalesOrderCollection}">
<columns>
<Column>
<header><Label text="Sales Order Id" /></header>
</Column>
<Column>
<header><Label text="Status" /></header>
</Column>
<Column>
<header><Label text="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:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
controllerName="table.MainView" xmlns:html="http://www.w3.org/1999/xhtml">
<Page title="Title">
<content>
<Table
headerText="Test Table"
items="{Order>/SalesOrderCollection}">
<columns>
<Column>
<header><Label text="Sales Order Id" /></header>
</Column>
<Column>
<header><Label text="Status" /></header>
</Column>
<Column>
<header><Label text="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?
the property need to be added wih the model name
<ObjectIdentifier
title="{moelName>/SoId}" />
<Text
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sandip,
thanks for your answer. I just gave it a try. Unfortunately it does not work, I still get empty rows.
<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
controllerName="table.MainView" xmlns:html="http://www.w3.org/1999/xhtml">
<Page title="Title">
<content>
<Table
headerText="Test Table"
items="{Order>/SalesOrderCollection}">
<columns>
<Column>
<header><Label text="Sales Order Id" /></header>
</Column>
<Column>
<header><Label text="Status" /></header>
</Column>
<Column>
<header><Label text="Created by" /></header>
</Column>
</columns>
<ColumnListItem
type="Navigation"
press="handleLineItemPress" >
<cells>
<ObjectIdentifier
title="{Order>/SoId}" />
<Text
text="{Order>/Status}" />
<Text
text="{Order>/CreatedByBp}" />
</cells>
</ColumnListItem>
</Table>
</content>
</Page>
</core:View>
User | Count |
---|---|
84 | |
9 | |
9 | |
8 | |
7 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.