Hello,
I'm getting started with SAPUI5 these weeks and built my first app that displays some data. I even managed to do some filtering but now I encounter an error that I do not understand.
My oData Model has the following structure:
Notice('0000'):
Value0: abc
Value1: def
Value2: ghi
Notice('0001'):
Value0: abc
Value1: def
Value2: ghi
I have a table holding the data:
<Table
id="noticeList"
class="sapUiResponsiveMargin"
width="auto"
items="{
path : '/Notice',
sorter : {
path : 'Value0'
}
}">
...some header stuff and column delaration...
<items>
<ColumnListItem
id="noticeColumnListItem"
items="{
path : '/Notice'
}">
<cells>
<ObjectStatus text="{Value0}"/>
<ObjectStatus text="{Value1}"/>
<ObjectStatus text="{Value2}"/>
</cells>
</ColumnListItem>
</items>
</Table>
|
Now, I want to access the Data of my Model (no matter if before or after rendering). I do not have a event to trigger this, I just need the information as soon as the model data was transferred.
So I searched a little and found the following:
var myValue = this.byId("noticeList").getModel().getProperty("/Notice/Value0");
I tried every possible path but always end up in that myValue is undefined. When I dump my model, I can see that it holds an object oData with the needed values. Also, my list is dispayed correct but I just don't manage to read a single value from the Model.
This is how I instanciate it in Component.js:
config: {
fullWidth : true,
resourceBundle: "i18n/messageBundle.properties",
serviceConfig: {
name: "MYJOBS",
serviceUrl: "/sap/opu/odata/sap/PATH_TO_SERVICE"
}
},
// Read service URL
var sServiceUrl = mConfig.serviceConfig.serviceUrl;
// Create and set domain model to the component
var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, {
json: true,
loadMetadataAsync: true
});
oModel.attachMetadataFailed(function() {
sap.ui.getCore().getEventBus().publish("Component", "MetadataFailed");
}, this);
//var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl);
this.setModel(oModel);
Maybe I should also mention that I don't use index.html to load the app but do this via Fiori Launchpad and Component.js
I spent hours over hours on this problem and can't find a solution, I hope someone can help...
Kind regards!