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

Delete record in LWC

HI All,

How to delete the record without refresh, becuse record added partially added into data table is not committed into database(in LWC).

Yogesh KanakiYogesh Kanaki
Hey @KMK91 could you please share your code.
Arun Kumar 1141Arun Kumar 1141



In Lightning Web Components (LWC), you can delete a record without refreshing the entire page by using JavaScript to perform the deletion and then updating the data displayed in your component. If the record has been partially added to a data table but not committed to the database, you can still delete it from your UI and update your data table accordingly. Here's a general outline of how to achieve this:

  • Create a Delete Button: In your LWC component, create a delete button for each record you want to delete.
<template for:each={records} for:item="record">
  <tr key={record.Id}>
    <!-- other columns -->
Implement the Delete Functionality: In your LWC JavaScript file, implement the handleDelete function to delete the record when the delete button is clicked. You can use the lightning-record-edit-form or Apex methods to delete the record.
import { LightningElement, api, wire } from 'lwc';
import { deleteRecord } from 'lightning/uiRecordApi';

export default class MyComponent extends LightningElement {
  @api records;

  handleDelete(event) {
    const recordId =;

      .then(() => {
        // Remove the deleted record from the records array
        this.records = this.records.filter(record => record.Id !== recordId);
      .catch(error => {
        // Handle error here
        console.error('Error deleting record: ', error);
I Hope this will help you.
chu jaschu jas
To delete a record without refreshing the page in a Lightning Web Component (LWC), you can use the Lightning Data Service (LDS) or Apex to perform the deletion operation on the client side. This allows you to remove the record from the data table without committing it to the database until explicitly saved by the user. You can also visit the Salesforce program website ( learn how to integrate this code.
Brittney PittmanBrittney Pittman
We need to import interface refreshApex for refreshing data table once a row is deleted.
Tommy HyattTommy Hyatt
Thanks for the info online games (