Friday, 3 July 2015


Index/ Counter in the Visual force using Apex:Variable.


The requirement where index along with the each record repeated in the "apex:repeat"  tag. The following snippet will be helpful.



<apex:variable value="0" var="index" />
 <apex:repeat value="{!contacts}" var="contact">
                    <apex:variable var="index" value="{!VALUE(index) + 1}"/>
{!index} . {!contact.Name}
</apex:repeat>



<apex:variable value="0" var="index" /> 
       Create a variable of name "index" & initialize it to "0"

 <apex:variable var="index" value="{!VALUE(index) + 1}"/>
        Inside the loop increment the index value.

{!index}
        Use the index variable as above, where ever needed.


Happy Coding

No comments:

Post a Comment