function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Zeel ShethZeel Sheth 

is it possible to display 15000 records in lightning component without pagination?

hii,
  I want to display 15000 records in one page because i want to select all records. is it possible ? if yes , pls suggest me.

component
<aura:component controller="ZipCodeList">
    
    <aura:attribute name="terr_name" type="String" default=""/>
    
    <aura:attribute name="user" type="ET_MOSI_Zip_Code_Territory_Mapping__c" default="{ sobjectType: 'ET_MOSI_Zip_Code_Territory_Mapping__c'}"/>
    <aura:attribute name="rows" type="Map[]"/>
    <aura:attribute name="cols" type="Map[]"/>
    <aura:attribute name="selectedRows" type="List"/>
    <aura:attribute name="selection" type="List" access="PRIVATE"/>
    <aura:attribute name="user_iid" type="string"/>
    <aura:attribute name="selectedZipCodes" type="List"/>
    <aura:attribute name="isSelected" type="boolean"/>
    <aura:attribute name="isSelectAll" type="boolean" />
    <aura:attribute name ="zcode" type="ET_MOSI_Zip_Code_Territory_Mapping__c" />
    <aura:attribute name="idlink" type="string" />
    <aura:handler name="init" value="{!this}" action="{!c.init}" />
    <aura:attribute name="options" type="List" access="PRIVATE"/>
    <aura:attribute name="selectedValue" type="String" access="PRIVATE"/>
    
    <lightning:card title="Enter Parameter" iconName="standard:search">
        <div class="slds-form slds-p-around_x-small">
            <lightning:layout horizontalAlign="space" multipleRows="true">
                <lightning:layoutItem size="12"
                                      mediumDeviceSize="12"
                                      padding="around-small">
                    
                    <lightning:select name="terrid" label="Select a Territory:" aura:id="terrid" value="{!v.selectedValue}">
                        <aura:iteration items="{!v.options}" var="option">
                            <option text="{!option.label}" value="{!option.label}" selected="{!option.selected}"/>
                        </aura:iteration>
                    </lightning:select>
                    FSE Name:<force:inputfield aura:id="user_id"
                                               value="{!v.user.Service_User__c}"
                                               
                                               /> 
                    
                </lightning:layoutItem>
                
            </lightning:layout>
            
            
            
        </div>
    </lightning:card>
    
    
    <div class="slds-form slds-p-around_x-small">
        <lightning:layout horizontalAlign="space" multipleRows="true">
            <lightning:layoutItem size="12"
                                  
                                  mediumDeviceSize="11"
                                  padding="around-small">
                
            </lightning:layoutItem>
            <lightning:layoutItem size="12"
                                  mediumDeviceSize="1"
                                  padding="around-small">
                <lightning:button onclick="{!c.onInit}">Go</lightning:button>
            </lightning:layoutItem>
        </lightning:layout>
        
        
        
    </div>
    
    <lightning:card title="Zip Code List" iconName="standard:account">
        <table class="slds-table slds-table_bordered slds-table_striped slds-table_cell-buffer slds-table_fixed-layout">
            <thead>
                <tr class="slds-text-heading_label"> 
                    <th scope="col"><div class="slds-truncate" title="Select"><ui:inputCheckbox change="{!c.selectAllOpp}" 
                                                                                                aura:id="selectAll"/></div></th>   
                    <th scope="col"><div class="slds-truncate" title="ZipCode">Zip Code</div></th>
                    <th scope="col"><div class="slds-truncate" title="Territory Name">Territory Name</div></th>
                    <th scope="col"><div class="slds-truncate" title="Region">Service Region</div></th>
                    <th scope="col"><div class="slds-truncate" title="FSE">FSE Name</div></th>
                    
                </tr>
            </thead>
            <aura:iteration var="x" items="{!v.zcode}" >
                <tbody>
                    <!-- Use the Apex model and controller to fetch server side data -->
                    <tr>
                        <td><div class="slds-truncate"><ui:inputCheckbox aura:id="checkOpp" text="{!x.Id}"/></div></td>
                        <td><div class="slds-truncate" title="{!x.Name}"><a href="{!'/lightning/r/ET_MOSI_Zip_Code_Territory_Mapping__c/'+x.Id+'/view'}">{!x.Name}</a></div></td>
                        <td><div class="slds-truncate" title="{!x.Service_Territory__c}">{!x.Service_Territory__c}</div></td>
                        <td><div class="slds-truncate" title="{!x.Service_Region__c}">{!x.Service_Region__c}</div></td>
                        <td><div class="slds-truncate" title="{!x.Service_User__r.Name}">{!x.Service_User__r.Name}</div></td>
                        
                    </tr>
                </tbody>
            </aura:iteration>
        </table>
    </lightning:card>
    <lightning:layout>
        <lightning:layoutItem size="12"
                              mediumDeviceSize="11"
                              padding="around-small">
            
        </lightning:layoutItem>
        <lightning:layoutItem size="12"
                              mediumDeviceSize="1"
                              padding="around-small">
            <lightning:Button onclick="{!c.update}" >Update</lightning:Button>
        </lightning:layoutItem>
        
    </lightning:layout>
    
</aura:component>

controller.js
({
    onInit: function( component, event, helper ) {
        // proactively search on component initialization
        var terr_name = component.get( "v.selectedValue" );
        
        helper.handleSearch( component,event, terr_name );
    },
    
    init: function (cmp, event, helper) {
        helper.simulateServerRequest(
            $A.getCallback(function handleServerResponse(serverResponse) {
                cmp.set('v.options', serverResponse.terr_name);

                
                cmp.set('v.selectedValue', serverResponse.selectedterr);
            })
        );
    },
    
    selectAllOpp : function(component, event, helper)
    {
        var selectedHeaderCheck = event.getSource().get("v.value");
        var getAllId = component.find("checkOpp"); 
        if(! Array.isArray(getAllId)){
            if(selectedHeaderCheck == true){ 
                component.find("checkOpp").set("v.value", true);    
            }else{
                component.find("checkOpp").set("v.value", false);
            }
        }else{
            // check if select all (header checkbox) is true then true all checkboxes on table in a for loop  
            // and set the all selected checkbox length in selectedCount attribute.
            // if value is false then make all checkboxes false in else part with play for loop 
            // and select count as 0
            if (selectedHeaderCheck == true) {
                for (var i = 0; i < getAllId.length; i++) {
                    component.find("checkOpp")[i].set("v.value", true);
                }
            } else {
                for (var i = 0; i < getAllId.length; i++) {
                    component.find("checkOpp")[i].set("v.value", false);
                }
            } 
        }  
    },
    
     update: function( component, event, helper ) {
        // proactively search on component initialization
        var getId= component.get("v.zcode");
         var t = component.get("v.zcode").length;
         alert(t);
        //var action2 =component.get("c.viewSelected");
        var getAllId = component.find("checkOpp");
        var user_id = component.get( "v.user.Service_User__c" );
        alert(user_id);
        var selctedRec = [];
        if(! Array.isArray(getAllId)){
            if (getAllId.get("v.value") == true) {
                selctedRec.push(getAllId.get("v.text"));
            }
        }else{
            
            for (var i = 0; i < getAllId.length; i++) {
                if (getAllId[i].get("v.value") == true) {
                    selctedRec.push(getAllId[i].get("v.text"));
                }
            }
            
        } 
        component.set('v.selectedZipCodes', selctedRec);
        var selectedrows1 = component.get( 'v.selectedZipCodes' );
     
        helper.updateFields( component,event,helper, selectedrows1 ,user_id);
    }, 
    
   
})

helper.js
({
    
    handleSearch: function( component,event, terr_name ) {
        var action = component.get( "c.searchList" );
        action.setParams({
            terr_name: terr_name
        });
        action.setCallback( this, function( response ) {
            var name = response.getState();
            component.set("v.zcode", response.getReturnValue());
            component.find("selectAll").set("v.value", false);
            });
            
        $A.enqueueAction( action );
        
         
        
    },
    
    simulateServerRequest: function (onResponse) {
        setTimeout(function () {
            var serverResponse = {
                selectedterr: 'Ahemdabad',
                terr_name: [
                    { id: 1, label: 'Ahemdabad', selected: true },
                    { id: 2, label: 'Baroda' },
                    { id: 3, label: 'Rajkot' },
                    { id: 4, label: '101 - Portland' },
                    { id: 5, label: '203 - NYC' }
                ]
            };

            onResponse.call(null, serverResponse);
        }, 2000);
    },
    
    updateFields: function(component, event, helper,selectedrows1,user_id) {
       
        
        var action1 = component.get('c.Update2');
            
            
        action1.setParams({
            recordid: selectedrows1,
            user_id: user_id
        });
       
        action1.setCallback(this, function(response) {
            
            var state = response.getState();
            alert(state);
            if (state === "SUCCESS") {
                console.log(state);
                $A.get('e.force:refreshView').fire();
            }
    });
        $A.enqueueAction(action1);
        
        var urlevent = $A.get("e.force:navigateToURL");
        urlevent.setParams({
            
        })
        },
})

apex class
global class ZipCodeList {
    @AuraEnabled
    public static List<ET_MOSI_Zip_Code_Territory_Mapping__c> searchList( String terr_name ) {
        List<ET_MOSI_Zip_Code_Territory_Mapping__c> list1 = new List<ET_MOSI_Zip_Code_Territory_Mapping__c>();
        if ( String.isNotBlank( terr_name )     && terr_name.length() > 1 ) {
            List<List<SObject>> searchResults = [
                FIND :terr_name
                RETURNING ET_MOSI_Zip_Code_Territory_Mapping__c(
                    Id, Name, Service_User__r.Name ,Service_Territory__c,Service_Region__c  limit 1900   //limit for implement
                )
            ];
            list1 = searchResults[0];
        }
        return list1;
    }
    
    @AuraEnabled
    public static void  Update2(List<string> recordid, string user_id )
    {
        
        //List<string> recordid =  params[0].recordid;
        //string userId =  params[0].user_id;
        system.debug('hey'+recordid);
        system.debug(user_id);
        List<ET_MOSI_Zip_Code_Territory_Mapping__c> list1 = new List<ET_MOSI_Zip_Code_Territory_Mapping__c>();
        
        List<ET_MOSI_Zip_Code_Territory_Mapping__c> srsLst= [select Id, Name, Service_User__c ,Service_Region__c,Service_Territory__c from 
                                                                 ET_MOSI_Zip_Code_Territory_Mapping__c
                                                                 where Id in :recordid];
        
        for(ET_MOSI_Zip_Code_Territory_Mapping__c Z : srsLst)
        {
            Z.Service_User__c = user_id;
            list1.add(Z);
        }
        if(list1.size()>0){
            update list1;
        }
        
    }
    global class UpdateActionRequest
    {
        @AuraEnabled
        global List<string> recordid;
        
        @AuraEnabled
        global string user_id;
    }
}

also, how I use batch class in this . I have learned about this but couldn't understand perfectly.
thanks in advance,
Zeel
Sai PraveenSai Praveen (Salesforce Developers) 
Hi ,

Can you check the approach suggested by SFDXFOX in the below link.

https://salesforce.stackexchange.com/questions/237905/is-it-possible-to-display-15-000-records-in-lightning-component

If this solution helps, Please mark it as best answer.

Thanks,
 
mukesh guptamukesh gupta
Hi Zeel,

Please follow below url for your solution approach:

https://developer.salesforce.com/forums/?id=9062I000000Qv6UQAS

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh