on 04-21-2014 12:09 PM
Hello ,
I am trying to create Table control using XML view and binding data to it through controller onInit method.
XML View Code is as follows :
<core:View xmlns="sap.m" xmlns:l="sap.ui.layout" xmlns:core="sap.ui.core">
<l:VerticalLayout width="100%">
<l:content>
<Text id="description" class="marginAll" />
<Table id="idProductsTable" items="{
path:'/businessData'
}">
<headerToolbar>
<Toolbar>
<Label text="Products"></Label>
</Toolbar>
</headerToolbar>
<columns>
<Column>
<Label text="Product" />
</Column>
<Column>
<Label text="Supplier" />
</Column>
<Column>
<Label text="Dimensions" />
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<ObjectIdentifier title="{COUNTRY}" text="{COUNTRY}" />
</cells>
<Text text="{REGION}"></Text>
<Text text="{CITY}"></Text>
</ColumnListItem>
</items>
</Table>
</l:content>
</l:VerticalLayout>
</core:View>
Controller onInit method Code is as follows :
var oData = {
businessData : [ {
'COUNTRY' : "Canada",
'CITY' : "Toronto",
'REGION' : "US",
'LANGUAGE' : "English"
}, {
'COUNTRY' : "China",
'CITY' : "Bejeing",
'REGION' : "Ashia",
'LANGUAGE' : "Chinese"
} ]
};
var demoJSONModel = new sap.ui.model.json.JSONModel();
demoJSONModel.setData(oData);
sap.ui.getCore().getElementById("idProductsTable").setModel(
demoJSONModel);
Same thing when i tried with JS views , it worked however through XML view , I am getting empty table.
Is the data modeling correct for XML views?
Thanks,
Mahesh.
Hi,
add data-sap-ui-xx-bindingSyntax="complex" in bootstrap script.
see example code JS Bin - Collaborative JavaScript Debugging</title> <link rel="icon" href="h...
and XML example code at sapui5bin/SinglePageExamples/ODataDateTableFilter.html at master · qmacro/sapui5bin · GitHub
Regards,
Chandra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Chandra,
Thanks a lot for your help. Its working fine for me now after adding the line inside index.html.
As suggested by Sakthivel , I added controllerName and one more change i have done in controller .
// | sap.ui.getCore().byId("idProductsTable").setModel(demoJSONModel); |
this.getView().byId("idProductsTable").setModel(demoJSONModel); |
Thanks ,
Mahesh.
I've got it ! The reason for that is you bind items as below,
<Table id="idProductsTable" items="{
path:'/businessData'
}">
This pattern is followed if you wanna add a formatter/sorter/grouping.
As you don't do any of those you can bind items as below & it doesn't require data-sap-ui-xx-bindingSyntax="complex".
<Table id="idProductsTable" items="{/businessData}">
You've missed the controllerName property in the xml!
<core:View xmlns="sap.m" xmlns:l="sap.ui.layout" xmlns:core="sap.ui.core" controllerName="your-controller-name">
Regards
Sakthivel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.