on 07-28-2016 12:42 PM
Hi,
I have a button in my xml view which displays a popup on button click. I am able to display the popup using the concept of fragments. Now I want to display the data to these fragment from the odata dynamically. I have attached my fragment code (PFA).
Since this is the first view for my app I am not able to display data here but I am able to see the data if I bind it to a table.
Please provide your valuable suggestions. Waiting for a quick reply.
Thanks,
Srinivasan
Hi,
You need inherit models from view.
try: this.getView().addDependent(oFragmentInstance)
Regards,
Pau
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I had followed the link OpenUI5 SDK - Demo Kit for another fragment. I am able to display the data from the model there since it is view got by passing values to another view.
Hi,
I tried to bindElement with the id of the record I want to display. Still the data does not display in the fragment. Is there any other control where I can display some fields with their labels?
Regards,
Srinivasan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Srinivasan,
Did you bind the element or the property in the controller and also how you have included the fragment in your code in the view or in the controller?
Thanks
Viplove
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Viplove,
I have included the fragment using the below code in the controller of that view.
createticket: function(oEvent) {
// create popover
if (!this._oPopover1) {
this._oPopover1 = sap.ui.xmlfragment("popoverNavCon", "CustomerPortal.Popover", this);
this.getView().addDependent(this._oPopover1);
}
// delay because addDependent will do a async rerendering and the popover will immediately close without it
var oButton = oEvent.getSource();
jQuery.sap.delayedCall(0, this, function() {
this._oPopover1.openBy(oButton);
});
},
Further I added the model to the controller by
var oModel = new sap.ui.model.odata.ODataModel("/sap/c4c/odata/v1/c4codata/"); | ||
this.getView().setModel(oModel); | ||
this.getView().addDependent("/ServiceRequestCollection"); |
Hi Srinivasan,
You added the fragment as dependent that's correct : this.getView().addDependent(this._oPopover1);
this will make the model available to the fragment too, but you need to bind the entitySet to the container using bindElement() like this :
var container = sap.ui.core.Fragment.byId("popoverNavCon", "navCon");
//getting id of a fragment if fragment id is provided
//you can even use the page id instead of navCon(NavContainer id)
container.bindElement("/ServiceRequestCollection");
//binding entitySet to the container(parent), this will allow the child to //use the relative binding.
references:
1. Element Binding - User Interface Add-On for SAP NetWeaver - SAP Library
2. Retrieving Control Instances by their ID - UI Development Toolkit for HTML5 (SAPUI5) - SAP Library
thanks
Viplove
Hi Viplove,
I have changed the fragment code displaying the fields in a form for alignment purpose.
Do I still use bindElement in my controller. Below is the controller code regarding the popup
onLoad: function(oEvent) {
if (!this._oPopover1) {
this._oPopover1 = sap.ui.xmlfragment("customerpopupNavCust", "CustomerPortal.CustomerPopup", this);
this.getView().addDependent(this._oPopover1);
this._oPopover1.bindElement("/ServiceRequestCollection");
}
var oButton = oEvent.getSource();
jQuery.sap.delayedCall(0, this, function() {
this._oPopover1.openBy(oButton);
});
},
I have also changed the name of NavContainer id to "navCust".
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.