+ Start a Discussion
Mee SharmaMee Sharma 

aura:method -'not a function' error

My requirement is that when i check the checkboxes and click on delete button the records need to be deleted.
I am getting the following error while trying to click on delete button(created in parent cmp) which accesses the delete method in its child component.
Please help as I am not able to find out what is wrong..

"This page has an error. You might just need to refresh it. Action failed: c:Budgetdisplay$controller$delparent [chn.deletemethod is not a function] Failing descriptor: {c:Budgetdisplay$controller$delparent}"

Parent component
<aura:component>
<table>
<thead>
<!--data table-columns--->
 <lightning:button label="Delete"                         
                          variant="brand"
                          onclick="{!c.delparent}"/>                         
             
                    </thead> 
    <!-- ITERATION -->
             <tbody>
                      <aura:iteration items="{!v.expense}" var="e" indexVar="sNo">
                       <!-- Child Lightning Component --> 
                    <c:inlineedit aura:id ="inline" singleRec="{!e}"
                                     showSaveCancelBtn="{!v.showSaveCancelBtn}"
                                     sNo="{!sNo + 1}" />
            </aura:iteration>
</tbody>
</table>
</aura:component>

parent controller

delparent : function(component,event,helper){
      var chn = component.find("inline");
        chn.deletemethod();
    }

child component
<aura:component>
 <!--Table Row Start-->  
        <aura:method name="deletemethod" action = "{!c.delete}" access="global"/>       
       <tr class="slds-hint-parent" >
           <td>
           <ui:inputCheckbox aura:id="eachbox" text="{!v.singleRec.Id}" />
           </td>
    <!---other rows--->
         </tr>
</aura:component>

child controller
delete :function(component, event, helper){
    
    var delid = [];
    var getAllId = component.find("eachbox");
    console.log('getallid'+getAllId);
    
    if(! Array.isArray(getAllId)){
         if (getAllId.get("v.value") == true) {
           delid.push(getAllId.get("v.text"));
         }
     }
else{
      for (var i = 0; i < getAllId.length; i++) {
       if (getAllId[i].get("v.value") == true) {
         delid.push(getAllId[i].get("v.text"));
       }
      }
     }      
  
    console.log('testdelid'+delid);
    helper.deleteSelectedHelper(component, event, delid);
      
      },
    
sfdcMonkey.comsfdcMonkey.com
Hi Meenakshi,
 here is the sample post same as your requirement :
http://sfdcmonkey.com/2017/02/23/delete-multiple-records-using-checkbox-lightning-component/

Thanks, let us know if it helps you
Mee SharmaMee Sharma
Apologies if my requirement is unclear. I have placed the delete button in the parent component and not in the child component,hence i am using aura:method.But its not working and i am getting the error mentioned iny post
sfdcMonkey.comsfdcMonkey.com
you are create <aura:method name="deletemethod" action = "{!c.delete}" access="global"/> on child component and call it from parent component, can you share all codes (Lightning component + apex + js) here OR my email id sfdcmonkey@gmail.com so i can help you to solve this issue

Thanks