Hi Jessica,Below is an example for fixed headers and scrollbars in a table. This is just an example, you need to use this in your requirement. Apex class:
public class AccountController
{
public Account acc { get; set; }
public AccountController( ApexPages.StandardController stdcontroller )
{
acc = ( Account )stdController.getRecord();
if( acc.Id != null )
{
acc = [ Select Id, Website, Name, ( Select Id, Name, FirstName, Description, LastName from Contacts ) from Account where Id =: acc.Id ];
}
}
}
Visualforce Page:
<apex:page standardController="Account" extensions="AccountController" tabStyle="Account" id="pageId" title="Account" >
<style>
⌗tableDiv
{
overflow:auto;
height:281px;
}
</style>
<apex:form id="form" >
<apex:pageBlock title="Account Details">
<apex:outputPanel>
<table class="list" border="0" cellpadding="0" cellspacing="0">
<tr class="headerRow">
<th class="headerRow" style="width:10%;" > Name </th>
<th class="headerRow" style="width:45%;" > FirstName </th>
<th class="headerRow" style="width:45%;" > LastName </th>
</tr>
</table>
<div id="tableDiv">
<table class="list " border="0" cellpadding="0" cellspacing="0">
<apex:repeat value="{!acc.Contacts}" var="con" id="repeat" >
<tr class="dataRow">
<td class="dataCell" style="width:10%;" > {!con.Name} </td>
<td class="dataCell" style="width:45%;" > {!con.FirstName} </td>
<td class="dataCell" style="width:45%;" > {!con.LastName} </td>
</tr>
</apex:repeat>
</table>
</div>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
Try this code, and you will see fixed header. Let me know if you need any other help.
Thanks,Neetu
4 Antworten