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
krishna23krishna23 

Display header even if <apex:pageBlockTable> is passed an empty List

if page block table has no rows how to display only header columns section.

Thanks.......
Best Answer chosen by krishna23
Maharajan CMaharajan C
Hi Krishna,

You can use apex:column tag simply inside the pageblock like below:

<apex:pageBlockTable value="{!MyAccounts}" var="Account" >
<apex:column headerValue="ID" headerClass="TableTitle" value="{!Account.ID}" />
<apex:column headerValue="Name" headerClass="TableTitle" value="{!Account.Name}" />
</apex:pageBlockTable>

or

you can use the apex:facet inside the apex:colum

<apex:column > <apex:facet name="header">Name</apex:facet> {!contact.Name} </apex:column>
<apex:column > <apex:facet name="header">Phone</apex:facet> {!contact.Phone} </apex:column>


Can you please Let me know if it helps or not!!!

If it helps don't forget to mark this as a best answer!!!


Thanks,
Maharajan.C

All Answers

Maharajan CMaharajan C
Hi Krishna,

You can use apex:column tag simply inside the pageblock like below:

<apex:pageBlockTable value="{!MyAccounts}" var="Account" >
<apex:column headerValue="ID" headerClass="TableTitle" value="{!Account.ID}" />
<apex:column headerValue="Name" headerClass="TableTitle" value="{!Account.Name}" />
</apex:pageBlockTable>

or

you can use the apex:facet inside the apex:colum

<apex:column > <apex:facet name="header">Name</apex:facet> {!contact.Name} </apex:column>
<apex:column > <apex:facet name="header">Phone</apex:facet> {!contact.Phone} </apex:column>


Can you please Let me know if it helps or not!!!

If it helps don't forget to mark this as a best answer!!!


Thanks,
Maharajan.C
This was selected as the best answer
krishna23krishna23
Thanks, Maharajan for quick response