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
Sachin10Sachin10 

Dynamically render the column Names in Salesforce-URGENT

Hi,

 

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}"/>
</apex:column>

</apex:pageBlockTable>

 

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:-)

StenEStenE

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.

 

 

aballardaballard

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....)