cancel
Showing results for 
Search instead for 
Did you mean: 

Apply Image conditionally

Former Member
0 Kudos

Need to apply image based on the condition. Can you please help me how to apply image conditionally.

new sap.ui.commons.Image({

src : ("{Products>Imagedata}" == "test") ? "./Images/test.png" : "./Images/NoTest.png",

height : "30px"

});

Accepted Solutions (1)

Accepted Solutions (1)

saivellanki
Active Contributor
0 Kudos

Hi Santosh,

Use formatter. Will this sample help? Plunker

Image finds the src based on the country value.

Regards,

Sai Vellanki.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Santhosh,

Use formatter,based on binded value you can return required output,sample for the same below:

new sap.ui.commons.Image(

   {

  visible: {

   parts : ['src'],

  formatter : function(src) {

   return (src== "test") ? "./Images/test.png" : "./Images/NoTest.png";

  }

  

  }

  }

  ).bindProperty("src", "src")

Regards

Naveen S