function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Scott H.Scott H. 

lightning:datatable custom row selection

Hi,

Is there a way to enable row selection when a user clicks on the row of datatable, rather than just on the checkbox/radio button?

I'd imagine I could do this through a combonation of jquery and using the selectedRows object that is provided.

However I'd like to avoid that in favor of a method that would use just the default functionality of the datatable, I'm just not sure how to do that if its currently possible.

Thanks
Sunil MadanaSunil Madana
Hi Scott,
There is already an event available with lightning:datatable to do this.
http://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_datatable.htm

Example below:
<lightning:datatable
            columns="{! v.mycolumns }"
            data="{! v.mydata }"
            keyField="id"
            onrowaction="{! c.handleRowAction }"/>
Hope the above answer helps and please mark as correct answer so others can benefit from it.