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
Janno RipJanno Rip 

Delete a row in Lighting Component Table

Hello everyone,

I am getting started with Lighting Components and build my own first tabe. I am displaying all quotedocuments from all quotes on the opportunity level so that our sales sees all documents in one table and does not have to open every single quote. Here is what I got so far:

User-added image

Now with Sales being Sales they make mistakes and create quotedocuments (pdfs) they dont actually need. So they need to be able to delete these quotedocuments in this table. That is the point where I am stuck. I found some documentation but I always end up with deleting the entire opportunity. My biggest challenge is to access every single quotedocument based on the row the button is hit.

Here is my apex class:

public class JTo_ListOfPDFs {
public static List <Quote> getPDF(Id opportunityId) 
        return [SELECT Id,Name,CreatedDate,QuoteNumber,TotalPrice,(SELECT Id,CreatedDate,Name,ContentVersionDocumentId,QuoteId FROM QuoteDocuments )FROM Quote WHERE OpportunityId =  :opportunityId ORDER BY Id DESC];
The component
<aura:component controller="JTo_ListOfPDFs" implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
	<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:dependency resource="markup://force:editRecord" type="EVENT" />
    <aura:handler event="force:refreshView" action="{!c.doInit}" />

    <!--aura attributes--> 
    <aura:attribute name="quoteDocumentRows" type="Object[]"/>
    <aura:attribute name="recordId" type="Id" />

    <!--Page header-->
    <div class="slds-page-header" role="banner">
        <span class="slds-text-heading_medium">List of PDFs</span>
        <ui:button class="btn" press="{!c.setOutput}"/>

     <!--Lightning data table markup-->
    <table class="slds-table slds-table--bordered slds-table--cell-buffer">
		    <tr class="slds-text-title_caps">
                <th scope="col">
		        <div class="slds-truncate" title="Quote">Quote Number</div>
		      <th scope="col">
                    <div class="slds-truncate" title="Name">PDF</div>
		      <th scope="col">
		        <div class="slds-truncate" title="Date">Date</div>
                <th scope="col">
		        <div class="slds-truncate" title="Date">Delete</div>
   <aura:iteration items="{!v.quoteDocumentRows}" var="cell" >
     <aura:iteration items="{!cell.QuoteDocuments}" var="pdf"  >	

         <td data-label="Quote Number">
        <div class="slds-truncate" title="Quote Number">
            <a href="{! '/'+cell.Id}" target="_blank">{!cell.QuoteNumber} </a>

      <td data-label="PDF">
        <div class="slds-truncate" title="PDF">
            <a href="{!''+ pdf.Id}" target="_blank">{!pdf.Name} </a>
      <td data-label="Date"> <lightning:formattedDateTime year="numeric" month="numeric" day="numeric"  hour="2-digit" minute="2-digit" value="{!pdf.CreatedDate}" /> 
         <lightning:buttonIcon aura:id="deleteButton" iconName="utility:close" size="small" variant="border-filled" alternativeText="Close"/>
The controller
    doInit : function(component, event, helper){
The Helper
	getAllPDFs : function(component, event, helper) {
        var action = component.get("c.getPDF");
        action.setCallback(this, function(a){
            component.set("v.quoteDocumentRows", a.getReturnValue());
            opportunityId: component.get("v.recordId")
    setOutput : function(component, event, helper) {
        var editRecordEvent = $A.get("e.force:editRecord");
             "recordId": component.get("v.recordId")

Can anyone point me in the right direction?  That would be great.

Thanks in Advance!

AbhishekAbhishek (Salesforce Developers)

Try the code snippet as mentioned in the above blog.

For further reference check this too (

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Janno RipJanno Rip
Hi @Abhishek,

thanks for the quick reply. However this link seems to be dead to me.

User-added image
AbhishekAbhishek (Salesforce Developers) 
I can able to access this URL,

Try clear cache and cookies for the browser or Try Incongitino window, You can try in another browser.
Hi Janno Rip,

Please go through the below link to get delete functionality for row in the lightning data table component

I hope you find the above solution helpful. If it does, please mark it as Best Answer to help others too.

Thanks and Regards,
Sachin Arora