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
amrita h 7amrita h 7 

how to limit or control number of records in aura iteration?

I have a lightning component with aura iteration. i want to dspaly only up to 5 records in the boxes.
variable 'FslFromBox' is having around 70 records here. and i am displaying this in one single div box. In this box, i want only 5 records to be shown. rest of the records(after 5 iterations) should not be shown on the box.
how to achieve this?

Code is below.
<aura:attribute name="FslFromBox" type="list"/>
<div style="background-color:#1589ee" class="slds-col slds-size_3-of-12 fslContainer">
                <div class="userName">
                    <aura:iteration items="{!v.FslFromBox}" var="FslFromBox" indexVar="int">

                            <aura:if isTrue="{!and((FslFromBox.ASQ_12MM__c ge 30),(FslFromBox.ASQ_Close_Rate__c ge 0),(FslFromBox.ASQ_Close_Rate__c lt 10))}">
                             <div class="demo-only">
                                    <span>
                                        <lightning:formattedText value="{!FslFromBox.User__r.Name}"/></span>    
                                </div>
                            </aura:if>
                    </aura:iteration>
                </div>
</div>

 
Best Answer chosen by amrita h 7
Raj VakatiRaj Vakati
you can able to use the  start and  end 
 
<aura:component>

	 <aura:iteration items="1,2,3,4,5" var="item" start=1 end = 4 >
        <meter value="{!item / 5}"/><br/>
    </aura:iteration>

</aura:component>

https://developer.salesforce.com/docs/component-library/bundle/aura:iteration/specification

All Answers

Raj VakatiRaj Vakati
you can able to use the  start and  end 
 
<aura:component>

	 <aura:iteration items="1,2,3,4,5" var="item" start=1 end = 4 >
        <meter value="{!item / 5}"/><br/>
    </aura:iteration>

</aura:component>

https://developer.salesforce.com/docs/component-library/bundle/aura:iteration/specification
This was selected as the best answer
dandamudidandamudi
Please Use below code, if it solve your issue please make Upvote else please post your errors
<aura:attribute name="FslFromBox" type="list"/>
<div style="background-color:#1589ee" class="slds-col slds-size_3-of-12 fslContainer">
                <div class="userName">
                    <aura:iteration items="{!v.FslFromBox}" var="FslFromBox" indexVar="int">
                       <aura:if isTrue="{!int &lt; 5}"> 
                            <aura:if isTrue="{!and((FslFromBox.ASQ_12MM__c ge 30),(FslFromBox.ASQ_Close_Rate__c ge 0),(FslFromBox.ASQ_Close_Rate__c lt 10))}">
                             <div class="demo-only">
                                    <span>
                                        <lightning:formattedText value="{!FslFromBox.User__r.Name}"/></span>    
                                </div>
                            </aura:if>
                        </aura:if>
                    </aura:iteration>
                </div>
</div>

 
amrita h 7amrita h 7
@Raj Vakati,
Thanks its working. Only the change I made is put the numbers in string. start="1" end = "4"

@dandamudi,
This code dint work :(