Skip to content

Instantly share code, notes, and snippets.

@amitkumarRoy
Last active July 24, 2018 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amitkumarRoy/f733d2ca405bdfb7dc17ad7238145df2 to your computer and use it in GitHub Desktop.
Save amitkumarRoy/f733d2ca405bdfb7dc17ad7238145df2 to your computer and use it in GitHub Desktop.
({
getData : function(cmp) {
var action = cmp.get('c.getContacts');
var recordId=cmp.get('v.recordId');
action.setParams({recordId:recordId});
action.setCallback(this, $A.getCallback(function (response) {
var state = response.getState();
if (state === "SUCCESS") {
//console.log(JSON.stringify(response.getReturnValue()));
cmp.set('v.myData', response.getReturnValue());
} else if (state === "ERROR") {
var errors = response.getError();
console.error(errors);
}
}));
$A.enqueueAction(action);
},
onSave:function(cmp,event)
{
var editedRecords=cmp.find('contactDatatable').get("v.draftValues");
console.log('editedRecords'+JSON.stringify(editedRecords));
var action=cmp.get('c.updateContacts');
action.setParams({contactList:editedRecords});
action.setCallback(this,function(response)
{
var state=response.getState();
if(state='SUCCESS')
{
// console.log('success'+JSON.stringify(response.getReturnValue()));
var toastEvent=$A.get("e.force:showToast");
toastEvent.setParams({title:'Success Message',
message:'successfully Updated',
key:'info_alt',
type:'info',
mode:'pester'
});
toastEvent.fire();
}
else
{
console.log(state);
}
});
$A.enqueueAction(action);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment