on 08-17-2016 11:08 AM
Hi Experts,
I have got my oModel data in an array in the Component.js file. I have returned the array with an entity collection (PFA) and have bind the entity to the table with the code
aData = this.getOwnerComponent().getServiceRequestCollection();
console.log("table array", aData);
var oVizFrame3Model = new sap.ui.model.json.JSONModel(aData);
var oTable = oView.byId("idServiceTable");
oTable.setModel(oVizFrame3Model);
The table is displayed empty and from the console I found that "table array" is undefined. Some quick suggestions as to how to bind the data to the table would be really helpful.
Thanks,
Srinivasan
Any suggestions from other experts in the forum would be very helpful.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Srinivasan,
Try This code
etServiceRequestCollection: function() {
var oModel = new sap.ui.model.odata.ODataModel("/sap/c4c/odata/v1/c4codata/");
oModel.read("/ServiceRequestCollection?$filter= CustomerID eq '1001192'",{
success: function(oData, response) {
var jsonModel = new sap.ui.model.json.JSONModel({oData.results} )
sap.ui.getCore().setModel(jsonModel);
});
},
For in ur table try like this
<Table id="idServiceTable" inset="false"
items="{path:'/', sorter : { path: 'ID'} }">
or
<Table items="{/}" >
if any errors post it.
Thanks & Regards
Venkat
Hi Venkat,
Thank you for the reply. I have altered the code as you have suggested and further added below code
getServiceEntity: function() {
var aData = {service:this.getServiceRequestCollection()};
return aData;
},
I am able to get the array, but the EntityCollection(service) is undefined. Below is the code I tried to get the array in the controller
aData = this.getOwnerComponent().getServiceEntity();
console.log("table array", aData);
var oVizFrame3Model = new sap.ui.model.json.JSONModel(aData);
var oTable = oView.byId("idServiceTable");
oTable.setModel(oVizFrame3Model);
Regards,
Srinivasan
Hi Venkat,
The altered the code in my Component.js file as you have suggested is put below
getServiceCollection: function() {
var oModel = new sap.ui.model.odata.ODataModel("/sap/c4c/odata/v1/c4codata/");
oModel.read("/ServiceRequestCollection?$filter= CustomerID eq '1001192'", {
success: function(oData, response) {
var oResult = new sap.ui.model.json.JSONModel({service:oData.results});
sap.ui.getCore().setModel(oResult);
}
});
}
I got this model in my controller using the code sap.ui.getCore().getModel(); and have altered the table code as suggested.
Still I am facing the same issue. Hope I have not committed a silly mistake.
Please point it out if you find any.
Thanks,
Srinivasan
Hi,
It would be very helpful if the experts provide some suggestions regarding the same.
Thanks in advance,
Srinivasan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Jun, I will keep this in mind for any future posts.
The code where the odata is got in an array.
getServiceRequestCollection: function() {
var oModel = new sap.ui.model.odata.ODataModel("/sap/c4c/odata/v1/c4codata/");
sap.ui.getCore().setModel(oModel);
oModel.read("/ServiceRequestCollection?$filter= CustomerID eq '1001192'",{
success: function(oData, response) {
var oResult = [];
oResult = oData.results;
oResult = {service:oResult};
return oResult;
}
});
},
The code to bind it with the table:
oResult = this.getOwnerComponent().getServiceRequestCollection();
console.log("table array", oResult);
var oVizFrame3Model = new sap.ui.model.json.JSONModel(oResult);
var oTable = oView.byId("idServiceTable");
oTable.setModel(oVizFrame3Model);
Have built the table in xml view
<Table id="idServiceTable" inset="false"
items="{path:'/service', sorter : { path: 'ID'} }">
<columns>
<Column>
<Text text="Service Order"/>
</Column>
<Column>
<Text text="Product"/>
</Column>
<Column>
<Text text="Serial ID"/>
</Column>
<Column>
<Text text="Status"/>
</Column>
</columns>
<items>
<ColumnListItem type="Navigation" press="toDetail">
<cells>
<Text text="{ID}"/>
<Text text="{ProductID}"/>
<Text text="{SerialID}"/>
<Text text="{ServiceRequestLifeCycleStatusCodeText}"/>
</cells>
</ColumnListItem>
</items>
</Table>
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.