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
venkyyyvenkyyy 

Pageblock table fixed column headings without using javascript,

Hi all,

I am trying to get the records through pageblock table, in that if i scroll down for next records the column heading are not go up(fixed headings without using javascript..), for that can anybody give suggestion to achive it.

Thanks,
Venky.
 
Neetu_BansalNeetu_Bansal
Hi Venky,

For this, you need to create html table and then apply styling like this. Here accounts is list of Accoun binded from Controller class:
<style>
        #tableDiv
        {
            overflow:auto;
            height:281px;
        }
</style>

<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%;" > Phone </th>
		<th class="headerRow" style="width:45%;" > Amount </th>
	</tr>
</table>

<div id="tableDiv">
	<table class="list " border="0" cellpadding="0" cellspacing="0">
		<apex:repeat value="{!accounts}" var="acc" id="repeat1" >
			<tr class="dataRow">
				<td class="dataCell" style="width:10%;" > {!acc.Name} </td>
				<td class="dataCell" style="width:45%;" > {!acc.Phone} {!payWrp.contactName} </a> </td>
				<td class="dataCell" style="width:45%;" > {!acc.Amount} </td>
			</tr>
		</apex:repeat>
	</table>
</div>
Here the classes added in the table, helps in providing the look and feel of pageblock table.

Let me know if you need any other help.

Thanks,
Neetu
venkyyyvenkyyy
Hi Neetu, 

Thanks for the reply, and i am not getting exactly the solution, can u please give me a example with account standard controller.


Thanks,
Venky.
Neetu_BansalNeetu_Bansal
Hi Venky,

Use the below example:
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>
Let me know if you need any other help.

Thanks,
Neetu