You need to sign in to do that
Don't have an account?
shrayas 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>
<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>
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
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