javascript side:
RemoveClick: function(component, event, helper) {
var selCont = event.getParam("selectedJob");
var conts = component.get("v.wrplst");
var contsval = JSON.stringify(conts);
alert('contsval value::::' + contsval);
var Selndex = conts.indexOf(selCont);
alert('selIndex value :::' + Selndex);
var DeleteLen = conts.length;
//alert('deleteLen value::::' + DeleteLen);
var removeAction = component.get("c.removeRow");
removeAction.setParams({
"wrvalue": contsval,
"rowval": Selndex,
});
removeAction.setCallback(this, function(g) {
var state = g.getState();
if (state == 'SUCCESS') {
alert('success value');
} else if (state === 'error') {
alert('error value');
}
});
$A.enqueueAction(removeAction);
}
server:
@AuraEnabled
public static List <WrapperCriteria > removeRow(string wrvalue,integer rowval){
system.debug('::::: rowToRemove val :::::'+rowval);
List < WrapperCriteria > warpList = (List < WrapperCriteria > ) JSON.deserialize(wrvalue, List<WrapperCriteria >.class);
system.debug('::::::wrList value::::' + warpList);
if(!string.isBlank(string.valueof(rowval))) *//ERROR:Illegal arguments*
{
Action_Criteria__c acdelete = warpList[rowval].record;
list<Action_Criteria__c> listAc = new list<Action_Criteria__c>();
if(!string.isblank(acdelete.id))
{
Criteria_Master__c criteriaMaster = [select id,Name,Action_Criteria__c,(select id, Criteria_Master__c from Action_Criteria__r where id!=:acdelete.id ) from Criteria_Master__c where Id=:acdelete.Criteria_Master__c];
listAc = [select id, Criteria_Master__c from Action_Criteria__c where id!=:acdelete.id and Criteria_Master__c=:acdelete.Criteria_Master__c];
if(criteriaMaster.Action_Criteria__r.isEmpty())
{
criteriaMaster.Action_Criteria__c = false;
update criteriaMaster;
}
delete acdelete;
}
}
warpList.remove(rowval);
system.debug('wraper List *******'+warpList);
return warpList;
}
alert('selIndex value :::' + Selndex);
?