1

how can I get the row I clicked from table ?

so that I can recover the data I want. the click is working

  <aura:iteration items="{!v.data}" var="row">
                <tr class="slds-hint-parent" onclick="{!c.showRow }" >
                    <td data-label="OpportunityNumber__c" >
                        <div class="slds-truncate" title="{!row.OpportunityNumber__c}">{!row.OpportunityNumber__c}</div>
                    </td>
                    <td data-label="Date" > 
                        <div class="slds-truncate" title="{!row.CreatedDate}">{!row.CreatedDate}</div>
                    </td>
                    <td data-label="Nom Affaire" >  
                        <div class="slds-truncate" title="{!row.Name}">{!row.Name}</div>
                    </td>

                </tr>
            </aura:iteration>

constorller js

showRow:function(component,event,helper){
  console.log("it's work");
}   

1 Answer 1

0

Try this:

<tr class="slds-hint-parent" data-myid="some data" onclick="{!c.showRow }" >

Then in JS:

showRow:function(component,event,helper){
  console.log("it's work ", event.currentTarget.dataset.myid);
}
3
  • i try like this myid="{!row.OpportunityNumber__c}" then in js event.currentTarget.myid . I get undefined
    – Ach Jiren
    Jul 23, 2019 at 14:36
  • its event.currentTarget.dataset.myid Jul 23, 2019 at 14:38
  • it's work thank you
    – Ach Jiren
    Jul 23, 2019 at 14:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .