Skip to Content

first Item is not binding into detailpage in splitApp in SAPUI5

Hai Experts,

I am developing one splitApp application in webIDE from the standard template, in this application am passing one parameter from the other application to this application to filter the odata from the master list. I am getting the parameter in Component.js and the code is added below.

var oComponentData = this.getComponentData();
var Ltype = oComponentData.startupParameters.LeaveID[0];
window.localStorage.setItem("WindowLtype", Ltype);

after this am passing the above parameter value to filter in listItem under ListSelector.js.

this._oWhenListHasBeenSet
.then(function(oList) {
/*Custom code Starts*/
var Ltype = window.localStorage.getItem("WindowLtype"); //added code
var oFilterLeave = new sap.ui.model.Filter("LeaveType", //added code
sap.ui.model.FilterOperator.EQ, Ltype
);
oList.getBinding("items").filter(oFilterLeave); //seting to filter
// oList.getBinding("items").attachFilter(oFilterLeave);
/* Ends */
oList.getBinding("items").attachEventOnce("dataReceived",
function(oData) {
if (!oData.getParameter("data")) {
fnReject({
list: oList,
error: true
});
}
var oFirstListItem = oList.getItems()[0];
if (oFirstListItem) {
// Have to make sure that first list Item is selected
// and a select event is triggered. Like that, the corresponding
// detail page is loaded automatically
fnResolve({
list: oList,
firstListitem: oFirstListItem
});
} else {
// No items in the list
fnReject({
list: oList,
error: false
});
}
}
);
});

After adding the above filter,

var oFirstListItem = oList.getItems()[0];

am getting the above line as undefined. because of this in my application the initial binding is getting error. once the item is selected from the master page the binding is proper.

Please help me to resolve the above issue.

Thanks,

Muhsin

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Oct 15, 2017 at 11:19 PM

    Hi Muhsin,

    Could you please check if odata service returns data?

    Did you check console log returning any error?

    Add comment
    10|10000 characters needed characters exceeded