Pagination With Unlimited Records in Lightning

Pagination With Unlimited Records in Lightning

 

 

 

 

 

 

 

 

 

As you know, We can build the pagination by using Offset feature in SOQL, but this offset pagination has the limit to show the 2000 records, using StandardSetController, it can be reached to max 10000.

So, I have built this component to paginate the unlimited records. I hope it will help you to build pagination without any limit.

Features

  • This component will be capable of paginate the records for unlimited data. For example, here we have considered Account object.
  • Inline editing feature is enabled. So, you can edit and save the record.
  • Inline editing feature is applicable in bulk mode. So, you can edit multiple records in the table and save he records in the single-click.
  • It has the Search functionality and also it has the pagination feature in Search results.

Step 1: Create an Auto number field in the object from where we will fetch the records. Here, we have created an auto number field named “AccountReference” on Account object with displaying formatĀ ACR-{0000000000}

Step 2: Create an Apex Class named “UnlimitedPaginationController.cls”

Basically, the following three methods from the apex class are responsible to operate the pagination in LWC.

getAccounts() method is responsible to return Account records by starting Auto Number and ending Auto Number for each page.

searchAccounts() method is responsible to search accounts by search key coming from LWC.

saveAccounts() method is responsible to save the account records in bulk mode by JSON deserializing the information sent from LWC.

Step 3: Create a LWC bundle named “unlimitedPagination“.
First, we will update “unlimitedPagination.js-meta.xml”

Next, we will update “unlimitedPagaination.html” in this way.

Next, we will update “unlimitedPagaination.js” in this way.

Output

7,680 total views, 9 views today

Rating: 4.4/5. From 9 votes.
Please wait...
This entry was posted in Lightning Components, Lightning Web Component Open Source, Salesforce Lightning. Bookmark the permalink.