Lightning Data Service (LDS) - In simple we can say Visualforce Standard Controller in Lightning Component
- We can do CRUD (Create, Retrieve, Update/Edit, Delete) operations through Lightning Data Service without using Apex code.
- It also handles sharing rules and field level security.
- It improves performance and user interface consistency.
- Form based components is automatic field mapping with filed-level validation
lightning:recordViewForm - Display records with lightning:outputField
lightning:recordEditForm - Create or edit records with lightning:inputField
force:recordData - Display, create, edit, or delete records with granular customization
Loading a Record
lightning:recordForm
lightning:recordViewForm - If we need a custom layout
To display the field values on a record page, implement the flexipage:availableForRecordHome and flexipage:hasRecordId. The component automatically inherits the record ID.
Editing a Record
lightning:recordForm
lightning:recordEditForm - If you want to customize the form layout or preload custom values
Creating a Record
lightning:recordForm
lightning:recordEditForm - If you want to customize the form layout or preload custom values
Deleting a Record
To delete a record using Lightning Data Service, call deleteRecord on the force:recordData component, and pass in a callback function to be invoked after the delete operation completes. The form-based components, such as lightning:recordForm, don’t currently support deleting a record.
You can handle record loaded, updated, and deleted changes, applying different actions to each change type.
When loading a record in edit mode, the record isn’t automatically updated to prevent edits currently in progress from being overwritten. To update the record, use the reloadRecord method in the action handler.
0 Comments