on 10-26-2018 10:44 AM
Hi,
I'm creating a simple Split App using a template.
Because of the OData service specification, I had to make some changes to the manifest file and in the master.controller as well.
While starting the app I'm receiving
TypeError: mParams.firstListitem.getBindingContext(...) is undefined
In the console.
What am I doing wrong and how to repair this bug?
The manifest file and other parts of the app are good because the navigation works fine if I click anything on Master list, but it can't show first list element details by default.
Here is the code of problematic functions:
onInit: function() {
var oList = this.byId("list"),
oViewModel = this._createViewModel(),
iOriginalBusyDelay = oList.getBusyIndicatorDelay();
this._oList = oList;
this._oListFilterState = {
aFilter: [],
aSearch: []
};
this.setModel(oViewModel, "masterView");
oList.attachEventOnce("updateFinished", function() {
oViewModel.setProperty("/delay", iOriginalBusyDelay);
});
this.getView().addEventDelegate({
onBeforeFirstShow: function() {
this.getOwnerComponent().oListSelector.setBoundMasterList(oList);
}.bind(this)
});
this.getRouter().getRoute("master").attachPatternMatched(this._onMasterMatched, this);
this.getRouter().attachBypassed(this.onBypassed, this);
},
_onMasterMatched: function() {
this.getOwnerComponent().oListSelector.oWhenListLoadingIsDone.then(
function(mParams) {
if (mParams.list.getMode() === "None") {
return;
}
var sObjectId = mParams.firstListitem.getBindingContext().getProperty("Bukrs");
var sObjectId2 = mParams.firstListitem.getBindingContext().getProperty("Auditid");
var sObjectId3 = mParams.firstListitem.getBindingContext().getProperty("Commiteeid");
this.getRouter().navTo("object", {
objectId: sObjectId,
objectId2: sObjectId2,
objectId3: sObjectId3
}, true);
}.bind(this),
function(mParams) {
if (mParams.error) {
return;
}
this.getRouter().getTargets().display("detailNoObjectsAvailable");
}.bind(this)
);
},
Did you give your ODATA model a name inside of your manifest? Or change the named model of the master list?
So for example, If I have an ODATA service called "myService" It would be .getBindingContext("myService") and the same applies to a differntly named model for your master list.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is from the manifest
"dataSources": {
"mainService": {
"uri": "/SRV/sap/opu/odata/PRJ/PRJ_SRV/",
"type": "OData",
"settings": {
"odataVersion": "2.0",
"localUri": "localService/metadata.xml"
}
}
},
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "prj.i18n.i18n"
}
},
"": {
"dataSource": "mainService",
"preload": true,
"settings": {
"defaultBindingMode": "TwoWay"
}
}
},
I have never seen an URI beginning with "/SRV". All our URIs start with "/sap/opu/odata/".
But I do not think, that this is problem, because all communication to the ODataService should cause errors in this case. But to be sure, can you verifiy in the network pane of the debugger tools of your browser, that i.e. metadata of your odata service is loaded.
If metadata is loaded, you can take a deeper look inside mParams.firstListitem. Is this the right object? Who assigned it to mParams?
About the /SRV - for some reason, it's needed while I'm using the local IDE, but I have to remove it manually before deploying the app, and the communication between app and OData works fine (it reads, puts and updates data without a problem).
The mParams.firstListitem seems to be wrong since it's oModels and oBindingContexts are empty objects.
Hi Bartosz,
if your List is bound to "masterView" Model, you have to call mParams.firstListitem.getBindingContext("masterView").getProperty("Bukrs")
Best regards,
Christian.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
After removing
,group : true
from the
<List items="{ path: '/CommitteeSet', sorter: { path: 'Auditid', descending: false} }"[...]
in Master.view.xml the error stopped appearing.
Why does grouping have an impact on that?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you need show a bit more information about this piece, this.getOwnerComponent().oListSelector.oWhenListLoadingIsDone.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
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.