Lightning Datatable with Single Checkbox Selection

ezgif.com-crop
Datatable with single checkbox selection

Scenario

There has been a lot of requirements for lightning datatable with a single checkbox selection but it is not available in handy. I don’t know why people are looking for single checkbox selection instead of radio buttons (more appropriate solution ) for the same purpose. Anyways, Here I am detailing a lightning datatable with single checkbox selection.

Objective: A lightning custom datatable component with a single row checkbox selection

Prerequisites: Basic knowledge of lightning component, Javascript .

Solution

This implementation includes the following members. Here, we are mainly focusing on the view part of the component so, the server-side interaction of the component is not included in this implementation, you can develop it yourself, based on the requirement. Comment below if you need any help on that.

  • SimpleDatatable.cmp
  • SimpleDatatableController.js

SimpleDatatable.cmp

Please see the code comments for more details.

SimpleDatatableController.js

Please see the code comments for more details.

ezgif.com-crop
Datatable with single checkbox selection

Don’t forget to share the post if you like it & bookmark the blog for future references.

If you have any comments or doubts on this post, Please comment on the box below.

References

https://www.lightningdesignsystem.com/components/data-tables/

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_ui_inputCheckbox.htm

One thought on “Lightning Datatable with Single Checkbox Selection

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s