You need to sign in to do that
Don't have an account?

auracomponent: Not able to save the draftvalues to server
Hi Everyone,
I am trying to inline edit the data table.
I followed this example to update the draft values to the server.
http://simpluslabs.com/how-to-use-lightningdatatable/
<lightning:datatable aura:id="contactDatatable" columns="{! v.mycolumns }"
data="{! v.dates }"
keyField="id"
hidecheckboxcolumn="true"
onsave="{! c.saveTable }"
/>
saveTable:function (cmp,event,helper)
{
console.log('insavetable');
var draftValues = event.getParam('draftValues');
helper.onSave(cmp,draftValues);
},
onSave:function(cmp,draftValues)
{
console.log('onsave');
var tsId = cmp.get("v.timeSheetId");
alert(tsId);
console.log(tsId);
var action=cmp.get("c.updateTime1");
action.setParams({"tsId":tsId,"updatedTimeList":draftValues});
action.setCallback(this,function(response)
{
var state=response.getState();
if(state='SUCCESS')
{
// console.log('success'+JSON.stringify(response.getReturnValue()));
console.log('success');
}
else
{
console.log(state);
}
});
$A.enqueueAction(action);
},
@AuraEnabled
public static List < TimePeriod__c > updateTime1(String tsId, List < TimePeriod__c > updatedTimeList ) {
updatedTimeList=[select Id, Date__c,IsAlreadySubmitted__c,Status__c, Volunteer_Recurrence_Schedule__c,Volunteer_Hours__r.name, Time__c, Hours_Worked__c from TimePeriod__c where time__c =:tsId];
for(TimePeriod__c tp: updatedTimeList){
system.debug('SignIn__c'+tp.Sign_In__c); --> null values
system.debug('SignOut'+tp.Sign_Out__c);--> null values
system.debug('hoursworked'+tp.Hours_Worked__c);--> null values
}
system.debug('updated'+updatedTimeList);
update updatedTimeList;}
Can anyone help me to fix this issue? TIA
Thanks,
Sirisha
I am trying to inline edit the data table.
I followed this example to update the draft values to the server.
http://simpluslabs.com/how-to-use-lightningdatatable/
<lightning:datatable aura:id="contactDatatable" columns="{! v.mycolumns }"
data="{! v.dates }"
keyField="id"
hidecheckboxcolumn="true"
onsave="{! c.saveTable }"
/>
saveTable:function (cmp,event,helper)
{
console.log('insavetable');
var draftValues = event.getParam('draftValues');
helper.onSave(cmp,draftValues);
},
onSave:function(cmp,draftValues)
{
console.log('onsave');
var tsId = cmp.get("v.timeSheetId");
alert(tsId);
console.log(tsId);
var action=cmp.get("c.updateTime1");
action.setParams({"tsId":tsId,"updatedTimeList":draftValues});
action.setCallback(this,function(response)
{
var state=response.getState();
if(state='SUCCESS')
{
// console.log('success'+JSON.stringify(response.getReturnValue()));
console.log('success');
}
else
{
console.log(state);
}
});
$A.enqueueAction(action);
},
@AuraEnabled
public static List < TimePeriod__c > updateTime1(String tsId, List < TimePeriod__c > updatedTimeList ) {
updatedTimeList=[select Id, Date__c,IsAlreadySubmitted__c,Status__c, Volunteer_Recurrence_Schedule__c,Volunteer_Hours__r.name, Time__c, Hours_Worked__c from TimePeriod__c where time__c =:tsId];
for(TimePeriod__c tp: updatedTimeList){
system.debug('SignIn__c'+tp.Sign_In__c); --> null values
system.debug('SignOut'+tp.Sign_Out__c);--> null values
system.debug('hoursworked'+tp.Hours_Worked__c);--> null values
}
system.debug('updated'+updatedTimeList);
update updatedTimeList;}
Can anyone help me to fix this issue? TIA
Thanks,
Sirisha