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}"/>

Advertisements