Posts

Showing posts from July, 2020

Lightning component with drag and drop functionality to delete records.

Image
In the following example, we will see how to implement 'drag and drop' feature in lightning component . We will see a small example to implement this, I am using standard contact object and I will try to fetch the contacts in my component and delete one contact by dragging and dropping the contact into a recycle bin . Screenshots: - Apex: - public class getContact { @AuraEnabled public static List<Contact> getContactList(){ List<Contact> con = [SELECT Id, Name, Email FROM Contact]; return con; } @AuraEnabled public static void deleteContact(String contactId){ contact[] con = [SELECT Id,Name FROM Contact WHERE Id =: contactId]; try{ delete con; } catch (DmlException e){ } } } Component: - ListOfContact.cmp <aura:component controller="getContact"> <aura:handler name="init" value="{!this}" action="{!c.doInit}" /> <aura:attribute name="contact" type="Object" /> ...