How to implement Pagination in Lightning Component – Client Side(JS)

on

|

views

and

comments

Hi All, It has been quite a long time since I have posted a blog about lightning components. In this tutorial, we will see how to implement Pagination using Client Side Controller(JS) with Lightning Data table.

Scenario: – Mr. X is Sales Rep at ABC Company and X wants to see those records  (Opportunity/Lead) that have been created in last 30 days and wants to do some mass actions on the selected records.

Problem: – The main problem here is “There may be more than 1K or more records created in last 30 days and because of limitations of Salesforce we cannot show all the records into a single Component.”

Solution: –  Mr. Y, who is working as a developer suggested to use the concept of Pagination.

Implementation: – 

List of components used in this implementation

  • Pagination.cmp – Lightning Component to display the records.
  • PaginationController.js – Client Side Controller for above component and responsible for calling the helper(JS) method.
  • PaginationHelper.js – Client Side helper javascript file which is responsible for calling the Server side(Apex) methods and do all the stuff related to pagination.
  • PaginationController.apex – Server Side controller to fetch the records.
  • PaginationApp.app – Lightning App which includes Pagination.cmp lightning component and displays the result.

Below is the code snipet of the Lightning App

<aura:application extends=’force:slds’ >
                 <c:Pagination />
</aura:application>

Application

 

You can find the complete code from my Github Repo – “Here“.

Output with pagination

Pagination

If you have any issue/thoughts then please let me know in the comment section.

Sharing is caring 🙂

 

Amit Singh
Amit Singhhttps://www.pantherschools.com/
Amit Singh aka @sfdcpanther/pantherschools, a Salesforce Technical Architect, Consultant with over 8+ years of experience in Salesforce technology. 21x Certified. Blogger, Speaker, and Instructor. DevSecOps Champion
Share this

Leave a review

Excellent

SUBSCRIBE-US

Book a 1:1 Call

Must-read

How to Utilize Salesforce CLI sf (v2)

The Salesforce CLI is not just a tool; it’s the cornerstone of development on the Salesforce Platform. It’s your go-to for building, testing, deploying, and more. As one of the most important development tools in our ecosystem

Save the day of a Developer with Apex Log Analyzer

Table of Contents What is Apex Log Analyzer? Apex Log Analyzer, a tool designed with Salesforce developers in mind, is here to simplify and accelerate your...

Salesforce PodCast

Introduction Hey Everyone, Welcome to my podcast, the first-ever podcast in India for Salesforce professionals. Achievement We are happy to announce that we have been selected as Top...

Recent articles

More like this

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here

5/5

Stuck in coding limbo?

Our courses unlock your tech potential