Play Games

Search This Blog

Wednesday, October 23, 2019

Display elements of a list by skipping first few elements of it in visualforce page

We can display list by skipping specified number of elements using first attribute of <apex:repeat> tag.

Apex Code: DisplayElements
public class DisplayElements {
    public List<Integer> lstNumber {get;set;}
    public DisplayElements() {
        lstNumber = new List<Integer>();
        for(integer i=1; i<20; i++) {
            lstNumber.add(i);
        }
    }
}

Visualforce Page:

<apex:page controller="DisplayElements" id="thePage">
    <b>Elements after skipping first 5 elements:</b><br/>
    <apex:repeat value="{!lstNumber}" var="num" id="theRepeat" first="5">
        <apex:outputText value="{!num}" id="theValue"/><br/>
    </apex:repeat>
</apex:page>

Output:

No comments:

Post a Comment