1

My requirement is to get a common header for two apex:columns. I am iterating over pageblocktable.

I know i can use apex:facet for individual apex:column but i dont what to repeat the same header for two columns.

Is there any way that i can achieve this.

  • Can you please elaborate on common header ? Do you want the same names for both the columns or do you want to show two field values under the same header? – Sam Aug 30 '13 at 7:01
  • I want to show two fields values (rather two columns) under same header. – rani Aug 30 '13 at 7:07
  • 1
    do you have some code for it? – Ashwani Aug 30 '13 at 7:34
  • Not possible with a standard visualforce. – Sergej Utko Aug 30 '13 at 8:27
3

What you can do is to "pack" two values into the one apex:column into the html table with two columns:

<style>
.tbl {
    border: none;
    width: 100%;
    margin: 0;
    padding: 0;
}
.tbl td {
    width: 50%;
    border: none !important;
    margin: 0;
    padding: 0;
}
</style>

<apex:pageBlock title="Block title">
    <apex:pageBlockTable value="{!accounts}" var="a" >
        <apex:column headerValue="My header">
             <table class="tbl"><tr><td>
             <apex:outputField value="{!a.Name}" /></td><td>
             <apex:outputField value="{!a.CustomerPriority__c}" />
             </td></tr></table>
        </apex:column>
        <apex:column value="{!a.Id}"/>
    </apex:pageBlockTable>
</apex:pageBlock>

The result:

enter image description here

| improve this answer | |
0

I had same issue with my visualforce page. So I simply added 2 outputFields inside a apex:Column and It works...!

<apex:pageBlockTable value="{!CampaignMemberList}" var="Cml" >
    <apex:column headerValue="Name" value="{!Cml.Name}"/>
    <apex:column headerValue="Status" value="{!Cml.Status}"/>
    <apex:column value="{!Cml.Attendence__c}"/> 
    <apex:column headerValue="Email" >
    <apex:outputField value="{!Cml.Contact.Email}" />
    <apex:outputField value="{!Cml.Lead.Email}" />
    </apex:column>
</apex:pageBlockTable>
| 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.