[SalesForce] Save record on button click

I have a list of records displayed on lightning component using

There are Save buttons corresponding to each record. The fields of the records are editable. I want to save the record, the corresponding button of which has been clicked. Other records will not be saved. I would like to understand, how to save this particular record. I am very new to lightning and any sample code would be really helpful.

Best Answer

What you're looking for is very similar to the app project on Salesforce TrailHead - Build a Lightning App with the Lightning Design System

The idea is to split the task into two components: - List - will hold the list of records - Editor - will hold data about specific record and allow you to save it

The following is general approach:

  1. List would get list of records from Apex controller on init even handler
  2. List would iterate over the list of records and display Editor component for each record
  3. Editor would have a form with a save button
  4. Clicking save button on Editor form would call Apex controller to save data
Related Topic