cancel
Showing results for 
Search instead for 
Did you mean: 

Single Fragment With Multiple ValueForHelp

krushii
Explorer
0 Kudos
551

Hello Experts,

1) I Have Trying a example, Created a view it have have some input fields with more than one ValueForHelp, data coming from Back End OData service.

2) I have a single fragment file for a popup, I want to display different different values in popup for every different valueForHelp with using single popup fragment

How do i do this.

View Entire Topic
shreyashrangrej
Participant
0 Kudos

Hi Rushi,

To display different values in a popup for different values helps in SAP UI5, you can use the following steps:

1. Create a single fragment file for the popup that includes the necessary UI elements for displaying the values. This might include elements such as labels, text fields, tables, etc.

2. In your view, create an instance of the fragment and add it to the view as the content of the popup. You can do this using the sap.ui.xmlfragment method, as shown in the following example:

// In the view
<Popup id="popup">
  <content>
    <core:Fragment fragmentName="myFragments.Popup" type="XML" />
  </content>
</Popup>

// In the controller
var oPopup = this.byId("popup");

// Set the values for the UI elements in the fragment
oPopup.byId("label").setText("Some text");
oPopup.byId("textField").setValue("Some value");
3. In the controller of your view, bind the UI elements in the fragment to the data coming from the OData service using the bindElement method. You can specify a different path for each value help by using the sPath parameter of the bindElement

method, as shown in the following example:

// In the controller
var oPopup = this.byId("popup");


// Bind the UI elements in the fragment to the data for the first value help
oPopup.byId("label").bindElement({
  path: "/EntitySet1(Key='key1')"
});
oPopup.byId("textField").bindElement({
  path: "/EntitySet1(Key='key1')"
});


// Bind the UI elements in the fragment to the data for the second value help
oPopup.byId("label").bindElement({
  path: "/EntitySet1(Key='key2')"
});
oPopup.byId("textField").bindElement({
  path: "/EntitySet1(Key='key2')"
});