Assign image source dynamically in XML View in Fiori app in SAP UI5


Yes, it can be done but you need to compute the dynamic field.

Firstly, you need to mention that the binding is complex so change the flag −

“data-sap-ui-bindingSyntax="complex" ”. 

Then have a helper function which can be used for formatting.

fnImageFmtr: function(value) {
   var imgSrc = "Image" + value;
   return imgSrc;
}

And lastly, use the function in the image tag in the XML view.

<Image src="{path:'<Model Property>',formatter:'. fnImageFmtr}"/>

Updated on: 13-Feb-2020

640 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements