+ Start a Discussion
acrozieracrozier 

rendering based on field value

Hello,

 

I am trying to render datatables based on the values of two date fields matching, or not.  Below is the code I am trying to use, but it doesn't work.  Basically if the Start Date equals the End Date I want to populate one datatable and if not I want to populate the other.

 

<apex:dataTable rendered="{!IF(Job__c.Job_Start_Date__c == Job__c.Job_End_Date__c,true,false)}" style="font-family: Calibri, sans-serif; font-size: 12px" value="{!Job__c}" var="j" rowClasses="odd,even">
    
                    	<apex:column >
                        	<apex:outputtext value="{0,date,MM/dd/yyyy}">
                            	<apex:param value="{!j.Job_Start_Date__c}" />
                        	</apex:outputtext>
 -                 
                        	<apex:outputtext value="{0,date,MM/dd/yyyy}">
                            	<apex:param value="{!j.Job_End_Date__c}" />
                        	</apex:outputtext>
                    	</apex:column>
            
                	</apex:dataTable>            	
            	
                	<apex:dataTable rendered="{!IF(Job__c.Job_Start_Date__c = Job__c.Job_End_Date__c,true,false)}" style="font-family: Calibri, sans-serif; font-size: 12px" value="{!Job__c}" var="j" rowClasses="odd,even">
    
                    	<apex:column >
                        	<apex:outputtext value="{0,date,MM/dd/yyyy}">
                            	<apex:param value="{!j.Job_Start_Date__c}" />
                        	</apex:outputtext>                 
                        </apex:column>
                        	
                	</apex:dataTable>    

 

Best Answer chosen by Admin (Salesforce Developers) 
Rahul SharmaRahul Sharma

Hi,

 

you dont need two different datatables if you just want to hide one column.

try this:

<apex:dataTable style="font-family: Calibri, sans-serif; font-size: 12px" value="{!Job__c}" var="j" rowClasses="odd,even">

	<apex:column >
		<apex:outputtext value="{0,date,MM/dd/yyyy}">
			<apex:param value="{!j.Job_Start_Date__c}" />
		</apex:outputtext>
	-                 
		<apex:outputtext value="{0,date,MM/dd/yyyy}" rendered="{!(j.Job_Start_Date__c != j.Job_End_Date__c)}">
			<apex:param value="{!j.Job_End_Date__c}" />
		</apex:outputtext>
	</apex:column>

</apex:dataTable>  

 Let me know if it does not helps.

All Answers

PratzPratz

Can you please recheck the IF conditions?

Rahul SharmaRahul Sharma

Hi,

 

you dont need two different datatables if you just want to hide one column.

try this:

<apex:dataTable style="font-family: Calibri, sans-serif; font-size: 12px" value="{!Job__c}" var="j" rowClasses="odd,even">

	<apex:column >
		<apex:outputtext value="{0,date,MM/dd/yyyy}">
			<apex:param value="{!j.Job_Start_Date__c}" />
		</apex:outputtext>
	-                 
		<apex:outputtext value="{0,date,MM/dd/yyyy}" rendered="{!(j.Job_Start_Date__c != j.Job_End_Date__c)}">
			<apex:param value="{!j.Job_End_Date__c}" />
		</apex:outputtext>
	</apex:column>

</apex:dataTable>  

 Let me know if it does not helps.

This was selected as the best answer
acrozieracrozier

that worked, thank you