1

I have a pageBlockTable whose column headers are dynamically generated based on the date. I would like to hide any column whose date falls on a Sunday. Below is the sample of the code for one of the columns.

<apex:column >
    <apex:facet name="header">
        <apex:outputPanel >
            <apex:outputText value="{0, date, EEEE}">
                <apex:param value="{!NOW()}" />
            </apex:outputText>
        </apex:outputPanel>
    </apex:facet>
    <apex:outputText value="{!Appointment.Open__c}"/>
</apex:column>

Is it possible to set the rendered attribute of the column to the result of the boolean expression of whether the current day is Sunday?

1

VF route would be to do :

<apex:column rendered="{!IF((MOD(DATEVALUE(TEXT(today())) - DATE(0001,1,1),7))==1,false,true)}"/>

(OR)

IF you have a controller, get today's day using

Reference : How Can I Tell the Day of the Week of a Date?

declare a boolean

public boolean rendercolumn{get;set;}

initialize in constructor

rendercolumn= true;

in your pageblocktable / datatable method add:

Date d = System.today();
Datetime dt = (DateTime)d;
String dayOfWeek = dt.format('EEEE');
if(dayofweek == "Sunday"){
rendercolumn = false;
}

VF Page:

<apex:column rendered="{!rendercolumn}">
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.