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
OnurKOnurK 

Visualforce table with dynamic header

Hi all,

 

I want to mak a table and would like to use the days of the month as header. For example in January there would be 31 columns and February 28 coumns etc. Column headers can be 1 , 2, 3, 4 or anything else. Is there anyone can share a sample code with me?

 

Thank you all in advance. 

clouddev@surashriclouddev@surashri

I found below code in Visual force developer's guide (pg 171). You will have to use dynamicComponent.

 

The <apex:dynamicComponent> tag has one required attributecomponentValuethat accepts the name of an Apex

method that returns a dynamic component. For example, if you wanted to dynamically generate the title of a section header

differently if the deadline for a submitting form has passed, you could use the following markup and controller code:

 

<apex:page standardController="Contact" extensions="DynamicComponentExample">
<apex:dynamicComponent componentValue="{!headerWithDueDateCheck}"/>
<apex:form>
    <apex:inputField value="{!Contact.LastName}"/>
    <apex:commandButton value="Save" action="{!save}"/>
</apex:form>
</apex:page>

 

public class DynamicComponentExample 
{
   public DynamicComponentExample(ApexPages.StandardController con) { }
   public Component.Apex.SectionHeader getHeaderWithDueDateCheck() {
   date dueDate = date.newInstance(2011, 7, 4);
   boolean overdue = date.today().daysBetween(dueDate) < 0;
   Component.Apex.SectionHeader sectionHeader = new Component.Apex.SectionHeader();
   if (overdue) 
   {
       sectionHeader.title = 'This Form Was Due On ' + dueDate.format() + '!';
       return sectionHeader;
   } 
   else 
   {
       sectionHeader.title = 'Form Submission';
       return sectionHeader;
   }
}
}

 

Here SectionHeader is changing as per date. I think this is what you want ?

 

Thanks,

OnurKOnurK

Thank you for your comment,

 

I can clearly see your point but I am not planning to use the name of the field, I am planning to use number of days as column. Since these values are not in database, it looks like I need to create my own list and loop from this list.

 

It looks like I need to play with it little bit longer.

 

Thanks again.