Modify EndDate after user edit using taskbar

Hi
I need to modify the end date of a task, after the user has modified it using de taskbar.

Example: If a user edits a task using the task bar and sets the end date 04/30/2020 I need to modify that date to 04/27/2020

I am trying using the actioncomplete event but I cannot update the task data
Thanks

3 Replies

PP Pooja Priya Krishna Moorthy Syncfusion Team April 29, 2020 11:51 AM UTC

Hi Isaac, 
While moving the taskbar, taskbarEdited event gets triggered. Using this event, we can update the end date by using updateRecordByID method. Please find the below code example. 
<ejs-gantt ref = 'gantt' 
//... 
: taskbarEdited = "taskbarEdited"> 
</ejs-gantt> 
 
methods: { 
  taskbarEdited: function(args) { 
    if (args.data.ganttProperties.endDate.getTime() >= 1554463800000) { //when end date exceeds April 5, 2020 revert it to April 4 
      var ganttObj = this.$refs.gantt.ej2Instances; 
      var data = [{ TaskID: args.data.ganttProperties.taskId, EndDate: new Date('04/04/2019') }]; 
      ganttObj.updateRecordByID(data[0]); 
    } 
  } 
}, 
 
Please find the below sample link. 
 
Regards, 
Pooja K 



IC Isaac Cubas Lasso April 30, 2020 09:21 AM UTC


I finally found the problem. 

I was using the Duration property on the taskFields object, together with StartDate and EndDate. 

In this case the function ganttObj.updateRecordByID (data [0]) didn´t work and didn´t set the end date correctly.

You can check it in your example if you add duration: 'Duration', to the taskFields object.

Thanks


PP Pooja Priya Krishna Moorthy Syncfusion Team May 1, 2020 08:59 AM UTC

Hi Isaac, 
  
When duration field is mapped, the end date will be validated based on the start date and duration only. To render tasks with end dates as given in the data source we need to remove duration field. 
And also, we are happy to hear that your problem has been resolved. 
Please get back to us if you require further assistance on this. 
  
Regards, 
Pooja K. 


Loader.
Up arrow icon