Monday, November 3, 2014

Headervalue not displayed in apex column tag

We have observed a strange behavior in headervalue property in <apex:column>tag. Header value won't display value if it is present within <apex:repeat> tags.

We were having a requirement where we need to display opportunity and its related competitor's record in one row. First Column will display opportunity fields and other columns will display field from different competitors related to opportunity. Number of columns will vary based on number of competitors. In order to display dynamic columns, we used <apex:column>  tags within <apex:repeat> tag. There are few fields which are common to opportunity and competitor object. User should be able to edit these fields for opportunity as well as for competitor in same page.

Below is sample code

Output:








In order to resolve this, we used Visualforce Dynamic Components. We created pageblocktable in apex and refereed it VF page.

Below is Code sample
Output after using Visualforce Dynamic Components:









Hope this might help you.

For more info on Visualforce Dynamic Components, Check below links:

https://www.salesforce.com/us/developer/docs/pages/Content/pages_dynamic_vf_components_intro.htm
https://developer.salesforce.com/page/Dynamic_Visualforce_Components

Looking forward for everyone's comment and suggestions.