When i edit save the records with the inline edits and do save it with the save button: the edited values get saved in database but the component doesnt get refreshed it still displayed edited values in different color. It should refresh and the color change to shouldn't be there after refresh. How to handle this UI color change?
PFB Code: controller Code:
saveFunction:function(component, event, helper){
//Production Year Details/validation
event.getParam('draftValues').forEach(function(draftitem){
if(draftitem.Quantity__c==null || draftitem.Quantity__c < 0)
{
var toastEvent=$A.get("e.force:showToast");
toastEvent.setParams({title:'Validation Error',
message:'Quantity Cannot be Blank or Less than Zero for Production Years',
key:'info_alt',
type:'error',
mode:'pester'
});
toastEvent.fire();
}
});
helper.onSave(component,event);
}
helper function:
refreshDataTable : function(component) {
alert('inside refresh');
var refreshAction = component.get("c.getProductionYear");
var recordId= component.get('v.recordId');
refreshAction.setParams({
"OppId" :recordId
});
refreshAction.setCallback(this,function(data) {
alert(data.getState());
component.set('v.data', data.getReturnValue());
});
$A.enqueueAction(refreshAction);
},
onSave:function(cmp,event){
alert('In Onsave Method');
var editedRecords=event.getParam('draftValues');
var action=cmp.get('c.savePYRecords');
var recID=cmp.get('v.recordId');
action.setParams({"listPY":editedRecords,"id1":recID});
action.setCallback(this,function(response)
{
var state=response.getState();
if(state='SUCCESS')
{
// console.log('success'+JSON.stringify(response.getReturnValue()));
$A.get('e.force:refreshView').fire();
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);
}
var updatedList = response.getReturnValue();
cmp.set("v.data",updatedList);
this.refreshDataTable(cmp);
});
$A.enqueueAction(action);
}
component save function:
<lightning:datatable aura:id="PYearTable"
columns="{!v.columns}"
data="{!v.data}"
keyField="Id"
onsave="{!c.saveFunction}"
draftValues="{!v.draftValues }"
hideCheckboxColumn="true"
showRowNumberColumn="true" onrowaction="{!c.handleRowAction }" />