on 12-11-2015 9:25 AM
Hello all,
Does somebody knows an example or a tutorial to show a table which is bound to an OData query in a XML view (with all the steps you need to do in the controller and Component.js files)?
Thanks in advance,
Pieter
Hi Pieter,
As Maksim has correctly pointed you need to use items and not rows in your <Table> tag in the view. Try the below:
In your controller, add a name to the model while setting it to the table/view as below:
oItemModel = new sap.ui.model.json.JSONModel();
oHeaderModel.loadData(<service URL>,parameters);
view.byId("itemsTable").setModel(oItemModel,"tabModel");
In your view:
<Table id="itemsTable"
items="{path:'tabModel>/d/results'}">
Then within the <items> aggregation:
<items>
<ColumnListItem id="itemListItem">
<cells>
<Text text="{path:'tabModel>Description'}" />
</cells>
</ColumnListItem>
</items>
Regards,
Saurabh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Guys,
Im trying something similar - not really sure where Im going wrong. I get "No data" in the data section of the table. Can anyone help? Heres what Im doing
In the controller
onInit: function() {
oItemModel = new sap.ui.model.json.JSONModel();
oItemModel.loadData("http://111.11.1.11:8001/ABS_PACK/XSJS/LIST.xsjs");
this.getView().byId("itemsTable").setModel(oItemModel,"tabModel");
}
In the XML view
<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
controllerName="p_tst_ui_m.TABLE" xmlns:html="http://www.w3.org/1999/xhtml">
<Page title="Schemas">
<content>
<Table id="itemsTable"
items="{path:'tabModel>/results'}">
<columns>
<Column id="NAME" width="auto">
<Text text="Schema Name" />
</Column>
</columns>
<items>
<ColumnListItem id="itemListItem">
<cells>
<Text text="{path:'NAME'}" />
</cells>
</ColumnListItem>
</items>
</Table>
</content>
</Page>
</core:View>
This is what the JSON of my service looks like
{"results":[{"NAME":"SAMMY"}]}
Hi John,
Instead of setting the model to the core you can try setting it to your view which contains the table like below:
this.getView().byId("itemsTable").setModel(oItemModel,"tabModel");
Also, ensure that on your index.html file you have included the below within the bootstrap:
data-sap-ui-xx-bindingSyntax="complex"
Regards,
Saurabh
Hi Pieter,
try this code
in your view
<Table id="ID_CAUSETABLE" inset="false"> |
<columns> | ||||||
<Column id="col1"> | ||||||
<Text text="ID" /> | ||||||
</Column> | ||||||
<Column id="col2"> | ||||||
<Text text="NAME" /> | ||||||
</Column> | ||||||
</columns> | ||||||
</Table> |
in your controller
var aData = [{"Id":"E0001","Name":"ABC"},
{"Id":"E0002","Name":"DEF"},
{"Id":"E0003","Name":"GHI"},
{"Id":"E0005","Name":"JKL"} ];
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData(aData);
oCAUSE_TABLE.setModel(oModel);
oCAUSE_TABLE.setMode(sap.m.ListMode.SingleSelectLeft);
oCAUSE_TABLE.bindItems("/", new sap.m.ColumnListItem({
cells: [
new sap.m.Text({
text: "{Id}"
}),
new sap.m.Text({
text: "{Name}"
}),
]
}));
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jun,
I will explain my problem.
There are two views (one overview view and one list view). In the overview you can click on different categories, one of them is Orders with delivery block, and you will navigate to the second screen where a table of all these orders are displayed.
This is my init function of the List.controller.js file:
In the debugger, the oData will retrieve the correct data from the SAP System:
But all these values are not shown in the table of the view List.view.xml.
For the xml coding I didn't found a good example to use..
Kind regards,
Pieter
User | Count |
---|---|
85 | |
10 | |
9 | |
9 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.