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
Sumesh ChandranSumesh Chandran 

Pass id of the row to controller when clicking the datetime dropdown

I am trying to pass the id of the row when the lightning input component gets focus or when the dropdown is clicked. Please adivse!
<aura:iteration items="{!v.opps}" var="opp">
<tr>
<td data-label="Close Date">
                            <lightning:input class="slds-size_x-small slds-align_absolute-center" type="date" value="{! opp.CloseDate }" onchange="{!c.onDateChange}" onfocus="{!c.onDateFocus}"/>
                        </td>
</tr>
</aura:iteration>

 
Best Answer chosen by Sumesh Chandran
Raj VakatiRaj Vakati
Change your markup as below


refer this link 

https://github.com/forcedotcom/aura/issues/154

 
<aura:iteration items="{!v.opps}" var="opp">
<tr>
<td data-label="Close Date">
                            <lightning:input class="slds-size_x-small slds-align_absolute-center" type="date" name="{!item.Id}" value="{! opp.CloseDate }" aura-id="inputCmp"  onchange="{!c.onDateChange}" onfocus="{!c.onDateFocus}"/>
                        </td>
</tr>
</aura:iteration>


On Controller 
 
var inputCmp = component.find("inputCmp");
        var value = inputCmp.get("v.value");

Or
 
var changeValue = event.getParam("name") ;

​​​​​​​

All Answers

Raj VakatiRaj Vakati
Change your markup as below


refer this link 

https://github.com/forcedotcom/aura/issues/154

 
<aura:iteration items="{!v.opps}" var="opp">
<tr>
<td data-label="Close Date">
                            <lightning:input class="slds-size_x-small slds-align_absolute-center" type="date" name="{!item.Id}" value="{! opp.CloseDate }" aura-id="inputCmp"  onchange="{!c.onDateChange}" onfocus="{!c.onDateFocus}"/>
                        </td>
</tr>
</aura:iteration>


On Controller 
 
var inputCmp = component.find("inputCmp");
        var value = inputCmp.get("v.value");

Or
 
var changeValue = event.getParam("name") ;

​​​​​​​
This was selected as the best answer
Sumesh ChandranSumesh Chandran
Hello Raj,

The copmponent part was helpful, but the controller side, I got it working this way.
 
var value = event.getSource().get("v.name");