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
shrayas reddyshrayas reddy 

how to control the number of records displayed in table in following code. say there are 10 rec but i want to display only 2 or 3 then how should i approach?

<table class="slds-table slds-table_cell-buffer slds-table_bordered">
                    <thead>
                      <tr class="slds-line-height_reset">
                        <th  scope="col">
                          <div class="slds-truncate" title="Name">Name</div>
                        </th>
                       
                        <th class="" scope="col">
                          <div class="slds-truncate" title="Phone">Phone</div>
                        </th>
                        <th class="" scope="col">
                            <div class="slds-truncate" title="Email">Email</div>
                          </th>
                          <th class="" scope="col">
                            <div class="slds-truncate" title="Account Name">Account Name</div>
                          </th>
                       
                      </tr>
                    </thead>
                    <tbody>
                <template for:each={conts} for:item="contact" >
                   
                      <tr key={contact.Id}>
                        <th data-label="Name">
                          <div class="slds-truncate" >{contact.Name}</div>
                        </th>
                        <th data-label="Phone">
                          <div class="slds-truncate">{contact.Phone}</div>
                        </th>
                        <th data-label="Email">
                          <div class="slds-truncate">{contact.Email}</div>
                        </th>
                       
                        <th data-label="Account Name">
                          <div class="slds-truncate">{contact.Account.Name}</div>
                        </th>
                       
                      </tr>
                   
                    </template>
                       
                    </tbody>
                  </table>
SwethaSwetha (Salesforce Developers) 
HI Shrayas,

You might want to try pagination to set the number of records per page. See https://sfdcpanther.com/how-to-implement-pagination-in-lightning-web-component/ for code snippet.

Let me know in case of any follow-up queries.Thanks
mukesh guptamukesh gupta
Hi Shrayas,

First you need to check where is comming from 10 records then you need to change 10 to 3 according your requirement.

So first check in apex class method that's are returing number of records to display in list


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

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

Thanks
Mukesh 
shrayas reddyshrayas reddy
I know that like we can use offset in the soql but once i get ll the records i should have control to display only few records and then once i click view all then all the records should be displayed.