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
ShuchiMShuchiM 

fixed headers on apex:datatable

I am trying to display a datatable with fixed headers. How do i do that ? Here's my code:

 

<apex:dataTable value="{!apartments}" var="c" cellspacing="2" cellpadding="3px" width="100%" rules="rows">
  <apex:column  headerValue="Name">
    <apex:outputText value="{!c.name}" />
  </apex:column>

</apex:dataTable>

 

Any help will be greatly appreciated. 

 

Regards

Shuchi

mast0rmast0r

Try to use Header facet and CSS style class:

 

<style>
.myHeader {
    height:30px;
    /* define all style params for the header here */
}
</style>

<apex:dataTable value="{!apartments}" var="c" width="100%" rules="rows" headerClass="myHeader">
<apex:facet name="header">
    <apex:outputText value="MyHeaderText" />
</apex:facet> <apex:column headerValue="Name"> <apex:outputText value="{!c.name}" /> </apex:column> </apex:dataTable>

 

ShuchiMShuchiM

And then what style should i apply to get a fixed header?

mast0rmast0r

What do you want to do fixed? (width, height, ...)