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
Shamim clShamim cl 

How to know In the lightning data-table selected checkbox is a header or body checkbox?

Recently I work on the LWC data table, stuck on one issue. looking for suggestions/help!

In Data-table event (onrowselection) I need to know which checkbox I have selected. Is it a header checkbox or table-body checkbox?

You may help me to get the appropriate event or any specific property. Which fires only on the header checkbox or which helps me to clearly identify it's a header check box, not a body checkbox.

Datatable checkbox
Nagarjuna ParalaNagarjuna Parala
Hi @Shamim,

Thank you for reaching out. I faced the similar issue earlier but I brought a soultion here. Please reproduce the following items to reslove your issue.

1. First try to add onchange attribute in your tr tag.
Example: <tr key={abcQli.Id} id={abcQli.Id}  onchange={abacusRowClicked}> 
2. Next capture which row was clicked in  JS. Remove the first character as below and assign that in your varaible.
Example :
abacusRowClicked(event){
        var RowId = event.currentTarget.id;
        this.abacusRowId=RowId.replace('-0','');}
3. No you got which row you actually clicked. Try to get the event.detail or devent.traget.value etc., information based on your requreimet and desing accodingly.

I hope this will resolve your issue. Please do reach out if any further assistance required. Have a great day ahead!

Thank you
Nagarjuna