Salesforce Lightning: Playing with Datatable Rows

Gautam Kasukhela
2 min readApr 26, 2020

Business Requirement

I recently came across a need from a customer where the following was needed :

  1. Show a List of records (e.g. Contacts) to a user from which the user should be able to select only one record.
  2. If the user does not find the required Contact in the table then, the user should be provided with an option to create a new Contact on the same page.
  3. If the user is opting for creating a new contact then, the user should not be allowed to select a record from the list of records. In short, a user should either select a single record from the table or create a new one but not both.

Technical Components

  1. Show the list of records (with criteria as required )using a <lightning:datatable>
  2. Provide a checkbox for the user to indicate he/she wants to create a new Contact.
  3. Show a <lightning:recordEditForm> to capture the fields as required to be shown on the form.

Technical Solution

All the logic of handling the clicks of Checkboxes and disabling the checkbox on data table is done via Javascript. I have used the Aura Framework to get this done. Below is the link to the code for your reference:

Component in Action

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response