function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
punnoosepunnoose 

generating images based on the value of elemts in datacolumn

 

I have a datatable in page  and all the values are displayed in the table,

now in one column i want to display images based on different values of  a.asset_type

How do i do that??

regards

Punnoose


<apex:dataTable id="hh1" value="{!Assets}" var="a" columnswidth="50px,50px,50px,50px,50px,50px" cellpadding="4" border="1" styleClass="container_tree_csv">
              ........
                 <apex:column headerValue="Asset Type">           
                    <apex:outputText value="{!a.asset_type}"/>
                </apex:column>
            </apex:dataTable>

Navatar_DbSupNavatar_DbSup

Hi,

You can use the <apex:outputPanel> with rendered attribute in apex column for display the image on the basis of a.asset_type

Try the below code snippet as reference:

 

 

<apex:dataTable id="hh1" value="{!Assets}" var="a" columnswidth="50px,50px,50px,50px,50px,50px" cellpadding="4" border="1" styleClass="container_tree_csv">

              ........

                 <apex:column headerValue="Asset Type">          

                    <apex:outputText value="{!a.asset_type}"/>

                </apex:column>

                                                               

                                                                <apex:column headerValue="Asset Type">          

                 <apex:outputPanel rendered ="{!IF(a.asset_type='a',true,false)}">

                                                                 <apex:image url="{!urlFOR('image url')}"/>

                                                                 </apex:outputPanel>

                </apex:column>

                                                               

            </apex:dataTable>

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

 

  

punnoosepunnoose

This works fine based on two values i need to give two images if 1 i need to display a pdf image if 2 i need another image.

How do i do that

Navatar_DbSupNavatar_DbSup

Hi,

 

You can also use the IF condition in url attribute of <Apex:image>.

 

Try the below code snippet as reference:

 

   <apex:image url="{!IF(condition,url1,url2))}"/>

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.