Skip to main content

Client Side Pagination using Lightning Component


This post describes, how to show Pagination on Lightning Datatable using reusable client side lightning pagination component. Pagination component is a reusable component and can be used any where using data table by passing two input parameters
currentPageNumber
maxPageNumber


Below are the steps to create a component to display the List of contacts and can able to paginate based on the records per page selection.

Step 1: Create a Pagination Component(Pagination.cmp)
Copy the below code to Pagination.cmp file
https://github.com/NagarjunaKaipu/myLightning/blob/master/ContactListDisplay.cmp

Copy the below js code to PaginationController.js file
https://github.com/NagarjunaKaipu/myLightning/blob/master/PaginationController.js

Step 2: Create Contact List component(ContactList.cmp)
Copy the below code to ContactList.cmp file
https://github.com/NagarjunaKaipu/myLightning/blob/master/ContactList.cmp

Copy the below js code to ContactListController.js file
https://github.com/NagarjunaKaipu/myLightning/blob/master/ContactListController.js

Step 3:
Test the component using Lightning Test Application(Test.app)


   


Sample Output:


Comments

Popular posts from this blog

Get started with Simple Lightning Web Component(Bike Card)

Lightning web component HTML files all include the template tag. The template tag contains the HTML that defines the structure of your component. Let’s look at the HTML for a simplified version of the component. Paste the following into app.html (replacing any existing HTML in the file). bikeCard.html < template > < div id = "waiting" if : false = { ready } > Loading.. </ div > < div id = "dispaly" if : true = { ready } > < div > Name: {name} </ div > < div > Description: {description} </ div > < div > Category: {category} </ div > < div > Material: {material} </ div > < div > Price: {price} </ div > < div >< img src = { pictureURL } /></ div > </ div > </ template > The identifiers in the curly braces {} are bound to the fields of the same name in the corresponding JavaScript class. Here’s a JavaScript file to s...

Disable Document Download in Salesforce

Disable downloads for certain users based on the name of the file uploaded to Salesforce. We can use the following example code inside of a Apex class. This code essentially prevents files whose file name starts off with Kaipu- from being downloaded by anyone whose user role’s developer name is not Kaipu_Sales. Modify this code to suit your own purpose. Based on Role: public class ContentDownloadHandlerFactoryImpl implements Sfc.ContentDownloadHandlerFactory {    public Sfc.ContentDownloadHandler getContentDownloadHandler(List<ID> ids, Sfc.ContentDownloadContext context) {      // See if the user has the Kaipu Sales role (based on developer name field).      Boolean isSecretUser = [        SELECT Id        FROM UserRole        WHERE ID = :UserInfo.getUserRoleId()          AND DeveloperName = ' Kaip...

Display list of contacts using Lightning Datatable

Lightning datatable is a table that displays columns of data, formatted according to type. Important attributes includes data, columns, and keyField attributes.The keyField attribute is required for correct table behavior. It associates each row with a unique identifier. Component: ContactListDisplay.cmp Refer below link for the code on github https://github.com/NagarjunaKaipu/myLightning/blob/master/ContactListDisplay.cmp Client Side Controller: ContactListDisplayController.js ({ doInit : function (component, event, helper) { component. set ( "v.myColumns" ,[ {label: "Name" , fieldName: "Name" , type : "text" }, {label: "Title" , fieldName: "Title" , type : "text" }, {label: "Department" , fieldName: "Department" , type : "text" } ]); var conAction = component. get ( "c.getContacts" ); conAction.setCallb...