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
MarniMarni 

Adding Table Row Count or Row Numbers

I have a visualforce page that shows a related list and I was wondering if it was possible to add either a table row count at the bottom of a table or add row numbers?  I have tried a few different sets of code that I had found but nothing is working.   Any help would be great!  Thanks! Below is the e table:

 

<p><u>Related Claims</u></p>
<table id="claims" border="1" cellspacing="2" cellpadding="5">
<tr>
<th>Claim Number</th>
<th>Insured</th>
<th>Claimant Name</th>
<th>Policy Number</th>
<th>Claim Status</th>
<th>Date Reported</th>
<th>Examiner</th>
</tr>
<apex:repeat var="rc" value="{!Account.Claims__r}">
<tr>
<td>{!rc.Name} </td>
<td>{!rc.Insured_Lookup__r.name}</td>
<td>{!rc.Claimant_Name__c}</td>
<td>{!rc.Policy__r.name}</td>
<td>{!rc.Status__c}</td>
<td><apex:outputText value="{0,date,MM/dd/yyyy}"><apex:param value="{!rc.Date_Reported__c}"/></apex:outputText></td>
<td>{!rc.Assigned_Examiner2__r.name}</td>
</tr>
</apex:repeat>
</table>

Best Answer chosen by Admin (Salesforce Developers) 
Rahul SharmaRahul Sharma

Hi, check if this help:

 

<p><u>Related Claims</u></p>
 <apex:variable value="{!1}" var="count"/> 

<table id="claims" border="1" cellspacing="2" cellpadding="5">
<tr>
 <th>Row Count</th> 
<th>Claim Number</th>
<th>Insured</th>
<th>Claimant Name</th>
<th>Policy Number</th>
<th>Claim Status</th>
<th>Date Reported</th>
<th>Examiner</th>
</tr>
<apex:repeat var="rc" value="{!Account.Claims__r}">
<tr>

<td>{!FLOOR(count)} </td> 
<td>{!rc.Name} </td>
<td>{!rc.Insured_Lookup__r.name}</td>
<td>{!rc.Claimant_Name__c}</td>
<td>{!rc.Policy__r.name}</td>
<td>{!rc.Status__c}</td>
<td><apex:outputText value="{0,date,MM/dd/yyyy}"><apex:param value="{!rc.Date_Reported__c}"/></apex:outputText></td>
<td>{!rc.Assigned_Examiner2__r.name}</td>

<apex:variable var="count" value="{!count+ 1}"/>

</tr>
</apex:repeat>

<p/>
<b>Total number of rows : </b> {!FLOOR(count-1)}

</table>

 

 


All Answers

bob_buzzardbob_buzzard

You may be able to do this via javascript, by rendering a script snippet that increments the counter or iterating the table elements and counting them.  I tend to use a wrapper class to encapsulate the sobject and the additional information.  That way I can set the counters up server side and simply render the details as I would with any other list.

Rahul SharmaRahul Sharma

Hi Marni,

You can use <apex:variable> to give numbers to each of row.

Rahul SharmaRahul Sharma

Hi, check if this help:

 

<p><u>Related Claims</u></p>
 <apex:variable value="{!1}" var="count"/> 

<table id="claims" border="1" cellspacing="2" cellpadding="5">
<tr>
 <th>Row Count</th> 
<th>Claim Number</th>
<th>Insured</th>
<th>Claimant Name</th>
<th>Policy Number</th>
<th>Claim Status</th>
<th>Date Reported</th>
<th>Examiner</th>
</tr>
<apex:repeat var="rc" value="{!Account.Claims__r}">
<tr>

<td>{!FLOOR(count)} </td> 
<td>{!rc.Name} </td>
<td>{!rc.Insured_Lookup__r.name}</td>
<td>{!rc.Claimant_Name__c}</td>
<td>{!rc.Policy__r.name}</td>
<td>{!rc.Status__c}</td>
<td><apex:outputText value="{0,date,MM/dd/yyyy}"><apex:param value="{!rc.Date_Reported__c}"/></apex:outputText></td>
<td>{!rc.Assigned_Examiner2__r.name}</td>

<apex:variable var="count" value="{!count+ 1}"/>

</tr>
</apex:repeat>

<p/>
<b>Total number of rows : </b> {!FLOOR(count-1)}

</table>

 

 


This was selected as the best answer
MarniMarni

That worked!  Thank you so much!

Venkat Reddy 6Venkat Reddy 6
good one...
Abhilash Gandhewar 5Abhilash Gandhewar 5
That's perfectly worked for me!  Thank you so much!