Dynamic image based on data from datagrid

Maarten Van Damme shared this question 5 years ago
Answered

Hi,


I was wondering if it is possible to have dynamic images in a datagrid. Example, if a person is male/female (based on the field 'Gender') the male or female icon is displayed (male.png, female.png).


I know one can specify the paths directly in the datagrid, but I want this to happen dynamically.


E.g. pseudocode:


IF field1.getText() = 'male'


THEN 'c:tempmale.png'


ELSE


'c:tempfemale.png'.


Thanks!


Maarten

Comments (2)

photo
1

Hi Maarten,


It's possible and you have two options to do it.


1. Create your data master and then add into your canvas a datagrid.


2. Now select the second row of this datagrid, as you can see in this photo.


eacced4e618e09da37d4ca19888353a0


3. Now go to add event and select "on page load". You have to include the following condition


4. Here you have two options. The first one is a "set value". In my example, as you can see, I included an empty photo element. Select it and select the photo from your PC that you want to use.


5. The other option is to add inside the datagrid both pictures in your case (male and female), hiding both. In this case, the action is a show a picture.


6. When you have done one of the options (steps 4 or 5), you have to click on the else button. Now you have to copy the condition and the action and just modify male for female and the picture to upload or show.


that's all. I hope it helps you

photo
1

Wonderful! Exactly how I intended it to be.


Thanks a lot for the exellent support, within a very limited time period.


Will need to get used to the way of creating conditions but the wizard is awsome :-)


Have a nice day!