You need to sign in to do that
Don't have an account?
xing gao 9
How to implement scrollable data table in lightning?
I need to implement a scrollable data table in my current project. The way I am doing it right now is to create two tables, one only contains header, and the other one only contains body.But this methods brings in problem with alignment. I see that in lightning standard page, there are scrollable tables, so wanna ask is there a standard way doing this that won't bring about any problems?
For vertical scroll you can use:
<div class="slds-scrollable--y">Scrollable Content Here</div>
There is two standard classes to fix this issue that are slds-table–header-fixed_container and slds-cell-fixed ,I have used this it's working for me , if you want only table body scrollable and header is fixed use this code.
<div class="slds-table--header-fixed_container" style="height:150px;">
<div class="slds-scrollable_y" style="height:100%;">
<table class="slds-table slds-table_bordered slds-table--header-fixed">
<thead>
<tr class="slds-text-title_caps">
<th scope="col">
<div class="slds-truncate slds-cell-fixed" title="Name">Name</div>
</th>
<th scope="col">
<div class="slds-truncate slds-cell-fixed" title="Total Number">Total Number</div>
</th>
<th scope="col">
<div class="slds-truncate slds-cell-fixed" title="Total Disbursement">Total Disbursement</div>
</th>
<th scope="col">
<div class="slds-truncate slds-cell-fixed" title="Balance">Balance</div>
</th>
</tr>
</thead>
<tbody>
<aura:iteration items="{!v.listOfRow}" var="option">
<tr>
<td data-label="Scholarship">
<div class="slds-truncate cls1" title="Name" >{!option.Name}</div>
</td>
<td data-label="No. Of Disbursement">
<div class="slds-truncate" title="Total Number">{!option.Number}</div>
</td>
<td data-label="Total Disbursement">
<div class="slds-truncate" title="Total Disbursement">$ {!option.Total}</div>
</td>
<td data-label="Balance">
<div class="slds-truncate" title="balance">$ {!option.balance}</div>
</td>
</tr>
</aura:iteration>
</tbody>
</table>
</div>
</div>