Posts

Showing posts with the label Datatable

How to implement client side pagination in LWC ?

Image
In this article, we are going to see how to implement client side pagination in LWC. Let say you have got requirement to get contacts from apex controller and display it in a table. But the catch here is there are 100s of records and now you have got the task to implement pagination such that you can also control how many records can be shown in the table from component only. So let's begin 1.Let's say we have got apex controller as below : @AuraEnabled(cacheable=true) public static List getMContact(String uId){ List cList = new List (); system.debug('The user Id is '+uId); User ug = [Select Id,Contact.AccountId from User WHERE Id =: uId LIMIT 1]; if(ug != null){ cList = [Select Id,Name,Phone,BirthDate,Email,MobilePhone,Role__c,is_Active__c from Contact WHERE AccountId =: ug.Contact.AccountId]; } system.debug('the count is '+cList.size()); return cList; } 2. Now ...