cancel
Showing results for 
Search instead for 
Did you mean: 

bindElement not working with sap.m.MessagePopover

0 Kudos

I am trying to get info from ToMessages and place it into the message popover. What is wrong?

oData Source

https://imodataservicep2001270708trial.hanatrial.ondemand.com/im-odata-service-2.0.0/Executions?$for...

Popover.fragment.xml

<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core">
<MessagePopover id="popoverNavCon">
<MessageItem title="{/results/0/Msgtx}"/>
</MessagePopover>
</core:FragmentDefinition>
Worklist.controller.js
handleMessagePopoverPress: function (oEvent) {
var oButton = oEvent.getSource();
var oContext = oButton.getBindingContext();
var sPath = oContext.getPath();
// create popover
if (!this._oPopover) {
Fragment.load({
id: "popoverNavCon",
name: "InterfaceMonitor.InterfaceMonitor.view.PopoverMessage",
controller: this
}).then(function (oPopover) {
this._oPopover = oPopover;
this.getView().addDependent(this._oPopover);
this._oPopover.bindElement(sPath + "/ToMessages/");
// this.getModel().read(sPath + '/ToMessages/results/Msgtx', {
// success: this.mySuccessHandler(sPath + '/ToMessages/results/Msgtx', ),
// error: this.myErrorHandler
// });
this._oPopover.openBy(oButton);
}.bind(this));
} else {
this._oPopover.bindElement(sPath + "/ToMessages");
this._oPopover.openBy(oButton);
}
},

Accepted Solutions (0)

Answers (3)

Answers (3)

maheshpalavalli
Active Contributor

Assuming it is the odata model, as it will send the navigation request for fetching for item details else i doubt json model will do that.

And the issue is you need to do bind element to the message popover with the sPath, not with the messages.

this._oPopover.bindElement(sPath)

Then in the message popover bind the items with the navigation property.

<MessagePopover items="{ToMessages}"> " Look no forward slash here 

then in the items do normal binding, see if the request will go in the network tab

example see below link at the end where they used "List"

https://sapui5.hana.ondemand.com/#/topic/91f05e8b6f4d1014b6dd926db0e91070

Thanks,
Mahesh

0 Kudos

This way it takes ALL the Msgtx's from oData.

handleMessagePopoverPress: function (oEvent) {
var oButton = oEvent.getSource();
var oContext = oButton.getBindingContext();
var sPath = oContext.getPath();
var oModel = this.getView().getModel();
var oModelLocal = this.getView().getModel("worklistView");
// create popover
if (!this._oPopover) {
Fragment.load({
id: "popoverNavCon",
name: "InterfaceMonitor.InterfaceMonitor.view.PopoverMessage",
controller: this
}).then(function (oPopover) {
this._oPopover = oPopover;
this.getView().addDependent(this._oPopover);
this._oPopover.bindElement(sPath);
this._oPopover.openBy(oButton);
}.bind(this));
} else {
this._oPopover.bindElement(sPath);
this._oPopover.openBy(oButton);
}
},
<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core">
<MessagePopover id="popoverNavCon" items="{ToMessages}">
<items>
<MessageItem title="{Msgtx}"/>
</items>
</MessagePopover>
</core:FragmentDefinition>

Is it possible to take only one, that relates to the row where the button is clicked? Please see the screenshot attached. Thank you in advance.

capture.png

junwu
Active Contributor
0 Kudos

first, bindelement don't need spath

second, this should be relative path.

<MessageItem title="{/results/0/Msgtx}"/>
0 Kudos

What does bindelement need to work properly?

junwu
Active Contributor
0 Kudos

if you want to bind to odatamodel directly

bindelement("modelname>/entityset(keys)")

it is jsonmodel

bindelement("modelname>/pathtotheelementinmodel")