0

I make a pagination for lightning for my list of objects. First part is great. But when i get to the last page (v.pages == v.page) - something goes wrong. Values for the number of objects are completely wrong. How can I fix that?

 <aura:if isTrue="{!v.pages > v.page}">
      {!v.objectsPerPageList.length * v.page - (v.objectsPerPageList.length - 1)}/{!v.objectsPerPageList.length * v.page} Objects • page {!v.page}/{!v.pages}
           <aura:set attribute="else">
               {!v.objectsPerPageList.length * v.page - (v.objectsPerPageList.length - 1)}/{!v.objectsPerPageList.length * v.page} Objects • page {!v.page}/{!v.pages}
           </aura:set>
 </aura:if>

For example, when I have 10 records on the 1 page (our step) and all records = 13, I get: 1/10 Objects • page 1/2 and 4/6 Objects • page 2/2. When I try it with 69 records = 7th page give me 55/63 Objects • page 7/7.

  • 2
    How are your values "completely wrong"? What values are you getting vs expecting? Also, there's a missing }, which I presume is a just a typo. Please double-check your code, and edit your question to include any additional details. – sfdcfox Jan 31 at 14:42
  • Sorry. Thank you. I edited. For example, when I have 10 records on the 1 page (our step) and all records = 13, I get: 1/10 Objects • page 1/2 and 4/6 Objects • page 2/2. When I try it with 69 records = 7th page give me 55/63 Objects • page 7/7. – MichaelLev19 Jan 31 at 14:51
  • 2
    This is too much logic to have in your view layer. You should use an <aura:attribute> and calculate this value in your controller. – Adrian Larson Jan 31 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.