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
nelloCnelloC 

Visibility of column header values

I have a couple of columns in a pageblocktable that have a headervalue specified. When there are no records to display in the table the headervalue is still rendered in the header whereas the default header labels from an object field do not display. In my example below, "Action" and "Name" remain visible in the header when no records are displayed:

 

<apex:pageBlockTable value="{!RelatedUsersList}" var="US">

<apex:column headerValue="Action">
<apex:commandLink action="{!DeleteDLUser}" reRender="user_list" onclick="window.confirm('Are you sure?');">
<b>Del</b>
<apex:param name="dluserid" value="{!US.Id}" assignTo="{!DeleteDLUserID}"/>
</apex:commandLink>
</apex:column>
<apex:column value="{!US.User__r.LastName}, {!US.User__r.FirstName}" headerValue="Name"/>
<apex:column value="{!US.User__c}"/>
<apex:column value="{!US.User__r.Email}"/>
</apex:pageBlockTable>

 

Is there a way of dealing with this to prevent the header values from displaying when the table is empty? It looks rather messy when the field labels are not displayed but any header values specified are still visible.

Message Edited by nelloC on 10-22-2009 08:38 AM
Best Answer chosen by Admin (Salesforce Developers) 
WesNolte__cWesNolte__c

Hey

 

You'd need to have a controller method that returned a boolean(preferably) to tell you if the dataset was empty. You could then use this value, together with the 'rendered' attribute of pageblocktable (check the component reference for this) and your table would behave in the required fashion.

 

Cheers,

Wes

All Answers

WesNolte__cWesNolte__c

Hey

 

You'd need to have a controller method that returned a boolean(preferably) to tell you if the dataset was empty. You could then use this value, together with the 'rendered' attribute of pageblocktable (check the component reference for this) and your table would behave in the required fashion.

 

Cheers,

Wes

This was selected as the best answer
nelloCnelloC

Wes, thanks for that. I've created a boolean property that's set in "RelatedUsersList" based upon whether records were retrieved from a select statement or not. As an instance of the dataset is not maintained in the controller I guess this is the best solution to determine whether the dataset is empty, don't you think?

 

Thanks again

Neal