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
Aruna VasahanAruna Vasahan 

pass object from lightning component to controller with onclick

I am having my component 
  

           
<aura:attribute name="persAccountList" type="Map" default="" />
     <table class="slds-table slds-table_bordered slds-table_cell-buffer">
              <thead>
                  <tr class="slds-text-title_caps">
                      <th>{!$Label.c.ACC_Select}</th>
               <th>{!$Label.c.Rforce_PersAcc_Lastname}</th>
                      <th>{!$Label.c.ACC_First_name}</th>
                      <th>{!$Label.c.ACC_Postal_Code}</th>
                      <th>{!$Label.c.ACC_City}</th>
                        <th>{!$Label.c.ACC_Email}</th>
                  <th>{!$Label.c.ACC_Last_Mobile}</th>
                  </tr>
                  </thead>
                  <tbody>
                  <aura:iteration items="{!v.persAccountList}" var="accountResult">
                      
                      <tr>
                          <td>  
      
              <input type="radio" name="select" value="" data-value="{!accountResult}" onclick="{!c.radioclick}"/></td>
                          <td>{!accountResult.lastName} </td>
                          <td>{!accountResult.firstName} </td>
                       <td>{!accountResult.zip} </td>
                           <td>{!accountResult.city} </td>
                           <td>{!accountResult.email} </td>
                           <td>{!accountResult.phoneNumber} </td>
                      </tr>
                      </aura:iteration>
                  </tbody>
              </table>



Here on the radio button with the onclick event I am trying to pass the record as a whole to my controller side. But I am not able to do so. Can anyone help me in this?
sfdcMonkey.comsfdcMonkey.com
HI try something like this :
<aura:iteration items="{!v.persAccountList}" var="accountResult">
                      
                      <tr>
					    <td>
                            <ui:inputRadio name="select" text="{!accountResult}" click="{!c.radioclick}"/>
                        </td>
              
                          <td>{!accountResult.lastName} </td>
                          <td>{!accountResult.firstName} </td>
                          <td>{!accountResult.zip} </td>
                           <td>{!accountResult.city} </td>
                           <td>{!accountResult.email} </td>
                           <td>{!accountResult.phoneNumber} </td>
                      </tr>
</aura:iteration>

javaScript :
radioclick : function(component,event,helper){
        var selectedObj = event.getSource().get("v.text"); // store selected object
		
		 alert(JSON.stringify(selectedObj)); // Print selected object value 
		
    }


Hope it will helps you
Thanks
Aruna VasahanAruna Vasahan
I am able to see it as a whole object, but I am not able to get the values inside it. When I try to get the values inside that its giving undefined.  User-added image
I want the firstname and lastname from the object. How to get that? I tried the below code, but not getting anything.
var selectedObj = event.getSource().get("v.text");
var d = JSON.stringify(selectedObj);
alert(d.lastname);