You need to sign in to do that
Don't have an account?
Mee 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);
},
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);
},
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
Thanks