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 data-label="Date" > 
                        <div class="slds-truncate" title="{!row.CreatedDate}">{!row.CreatedDate}</div>
                    <td data-label="Nom Affaire" >  
                        <div class="slds-truncate" title="{!row.Name}">{!row.Name}</div>


constorller js

  console.log("it's work");

Try this:

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

Then in JS:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.