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
Silambarasan VeluSilambarasan Velu 

display serial no of record in standard list control Visualforce pagination

Hi guyz,

I'm trying to  display serial number of record using vfp, standard list control. using below code:
 
<apex:variable var="rowNo" value="{!0}"/>
            <apex:pageblocktable value="{!cnts}" var="cnt">
                <apex:column headerValue="Sl.No">
                    <apex:variable var="rowNo" value="{!rowNo+1}"/>
                    {!rowNo}
                </apex:column>
using above code for first colum,
here my problem is while using pagination in second page also serial no starts with 1. instead of 11,12,13..etc.
kindly give suggestion.
i'm a learner.
 
Amit Chaudhary 8Amit Chaudhary 8
It look like your full page is rendering. Try to render only PageBlockTable only not full page.

Can you please post your full code so that i can help you
Shiva RajendranShiva Rajendran
Hi Silambarasan ,
I got the issue you are facing. We faced this issue on custom controller.
That time we made use of another one variable .
But i think in your case as Amit pointed out, i also feel the same .Things will work if rerender only the pagBlockTable
<apex:variable var="rowNo" value="{!0}"/>
            <apex:pageblocktable value="{!cnts}" var="cnt" id="pageBlockTable1">
                <apex:column headerValue="Sl.No">
                    <apex:variable var="rowNo" value="{!rowNo+1}"/>
                    {!rowNo}
                </apex:column>

 <apex:commandLink action="{!previous}" reRender="pageBlockTable1"=>Previous</apex:commandlink>
     <apex:commandLink action="{!next}" reRender="pageBlockTable1">Next</apex:commandlink>

This should work 
Thanks and Regards,
Shiva RV
 
Silambarasan VeluSilambarasan Velu
Hi Amit & Shiva,

here is my full code:
 
<apex:page standardController="Contact" recordSetVar="cnts">
    <apex:form >
        <apex:pageBlock title="Contact List" id="contacts_list">
            Filter:
            <apex:selectList value="{!filterId}" size="1">
                <apex:selectOptions value="{!listviewoptions}"/>
                <apex:actionSupport event="onchange" reRender="contacts_list"/>
            </apex:selectList>
            <apex:variable var="rowNo" value="{!0}"/>
            <apex:pageblocktable value="{!cnts}" var="cnt">
                <apex:column headerValue="Sl.No">
                    <apex:variable var="rowNo" value="{!rowNo+1}"/>
                    {!rowNo}
                </apex:column>
                <apex:column value="{!cnt.firstname}"/>
                <apex:column value="{!cnt.lastname}"/>
                <apex:column value="{!cnt.email}"/>
                <apex:column value="{!cnt.account.name}"/>
            </apex:pageblocktable>
            <table style="width: 100%"><tr>
            
            <td>
                Page: <apex:outputText value="{!pagenumber} of {!CEILING(resultsize/pagesize)}" />
            </td>            
            
            <td align="center">
                <apex:commandLink action="{!previous}" value="<<Previous" rendered="{!hasprevious}"/>
                <apex:outputText value="<<Previous" rendered="{!not(hasprevious)}"/>
                <apex:commandLink action="{!next}" value="Next>>" rendered="{!hasnext}"/>
                <apex:outputText value="Next>>" rendered="{!not(hasnext)}"/>
            </td>
            
            <td align="right">
                <apex:selectList value="{!pagesize}" size="1">
                    <apex:selectOption itemValue="5" itemLabel="5"/>
                    <apex:selectOption itemValue="20" itemLabel="20"/>
                    <apex:actionSupport event="onchange" reRender="contacts_list"/>
                </apex:selectList>
            </td>
            
            </tr>
        </table>
        
    </apex:pageBlock>
</apex:form>
</apex:page>

 
Amit Chaudhary 8Amit Chaudhary 8
Please update your code like below
<apex:page standardController="Contact" recordSetVar="cnts">
    <apex:form >
        <apex:pageBlock title="Contact List" id="contacts_list">
            Filter:
            <apex:selectList value="{!filterId}" size="1">
                <apex:selectOptions value="{!listviewoptions}"/>
                <apex:actionSupport event="onchange" reRender="contacts_list"/>
            </apex:selectList>
            <apex:variable var="rowNo" value="{!0}"/>
            
            <apex:pageblocktable value="{!cnts}" var="cnt" id="PB1">
                <apex:column headerValue="Sl.No">
                    <apex:variable var="rowNo" value="{!rowNo+1}"/>
                    {!rowNo}
                </apex:column>
                <apex:column value="{!cnt.firstname}"/>
                <apex:column value="{!cnt.lastname}"/>
                <apex:column value="{!cnt.email}"/>
                <apex:column value="{!cnt.account.name}"/>
            </apex:pageblocktable>
            <table style="width: 100%"><tr>
            
            <td>
                Page: <apex:outputText value="{!pagenumber} of {!CEILING(resultsize/pagesize)}" />
            </td>            
            
            <td align="center">
              <apex:outputPanel id="OP1">   
                <apex:commandLink reRender="PB1,OP1" action="{!previous}" value="<<Previous" rendered="{!hasprevious}"  />
                <!--
                <apex:outputText value="<<Previous" rendered="{!not(hasprevious)}"/>
                -->
                
                <apex:commandLink reRender="PB1,OP1" action="{!next}" value="Next>>" rendered="{!hasnext}"/>
                <!--
                <apex:outputText value="Next>>" rendered="{!not(hasnext)}"/>
                -->
                </apex:outputPanel>
            </td>
            
            <td align="right">
                <apex:selectList value="{!pagesize}" size="1">
                    <apex:selectOption itemValue="5" itemLabel="5"/>
                    <apex:selectOption itemValue="20" itemLabel="20"/>
                    <apex:actionSupport event="onchange" reRender="contacts_list"/>
                </apex:selectList>
            </td>
            
            </tr>
        </table>
        
    </apex:pageBlock>
</apex:form>
</apex:page>

Let us know if this will help you
 
nagalakshminagalakshmi
Hi Amit,

I am using similar kind of code to display serial number and pagination for it. It is displaying the serial number. when i click on next link it is moving to next set of records with serial numbers. When i click on previous, it is not giving previous set of serial numbers. Kindly help me to solve this issue.