+ Start a Discussion

Dynamically render the column Names in Salesforce-URGENT



I want to render the column header names dynamically in PageBlock Table as below:


Code Snippet

<apex:pageBlockTable border="2"  value="{!testList}" var="a" id="a">

<apex:column  headervalue="{!a.Field_Name__c}" rendered="{!NOT(ISNULL(a.Field_Name__c))}">
<apex:outputText value="{!a.Field_Value__c}"/>



The above snippet is just displaying the Value but not the header name


So as my Coulmn header I want to populate the Field Name.How can I acheive this?


Any help would be highly appreciated:-)


I have got the same issue.

As you render a html table, the header values need to be set before any rows are added. I think this is the problem here as well. When the pageblock table creates the header in html the value which you specificy is not jet available, as you aren't lopping through the rows at that stage.




You need to define the header with a value that isn't based on the iteration variable (which doesn't really make sense since that implies it could be different from one row to another... there is clearly only one header for the table....)