Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
How can I delete nested rows in Salesforce LWC

How can I delete nested rows in LWC

<template for:each={parentArray} for:item="parent" for:index="index">
    //Code for parent rows
    <template for:each={parent.childArray} for:item="child" for:index="indx">
          //Code for child rows
          <td>
             <lightning-button-icon icon-name="utility:delete" value={indx} variant="bare" onclick={handleRemove}></lightning-button-icon>
          </td>
    </template>
</template>

So, when I click on delete then I am able to get the index of the child row. How would I know that this row belongs to this parent row. Something like this:

this.parentArray[0].childArray.splice(index, 1);

Just like this. Here I have manually added the parent index but how can I get the index dynamically in my JS controller.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I have got my answer and I am posting it here if anyone faces the same issue then they can relate it. What I did. I just a used an attribute if the and passed my parent index there and the same I accessed in my JS controller

<template for:each={parentArray} for:item="parent" for:index="index">
//Code for parent rows
<template for:each={parent.childArray} for:item="child" for:index="indx">
      //Code for child rows
      <td>
         <lightning-button-icon icon-name="utility:delete" value={indx} variant="bare" onclick={handleRemove} name={index}></lightning-button-icon>
      </td>
</template>
const parentIndex = event.target.name;
this.parentArray[parentIndex].childArray.splice(index, 1);

It worked.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!