Monthly step

Hello,

I render the Gantt on a monthly base (I render tasks that have the full month of length).

is there a way to set the TaskBarEditing Drag and Drop on a task to act on a month by month basis? (es. Drop a task on 25th of february, force the day to be 1st of february).


Thank you in advance,

EF



3 Replies

PS Premkumar Sudalaimuthu Syncfusion Team April 4, 2022 09:58 AM UTC

Hi EF ,


We hope that your requirement is the taskbar returns to start date of the month when you drag and drop the taskbar on any date of the month. We have prepared a work around to achieve your requirement using actionBegin and actionComplete event. Please refer to the code snippets and sample for more information. If this is not your requirement, we request you to elaborate your requirement. It will help us to provide you with a better solution.


Code snippets:


public actionBegin(args: any) {

    if (args.requestType === 'beforeSave') {

      if (this.isUpdated) {

        this.isUpdated = false;

        this.ganttObj.timelineModule.refreshTimeline();

      }

    }

  }

  public actionComplete(args: any) {

    debugger;

    if (args.requestType === 'save') {

      if (!this.isUpdated) {

        var month = args.data.StartDate.getMonth();

        var date = args.data.StartDate.getDate();

        if (date != 1) {

          var sDate = new Date();

          var newDate = new Date(

            args.data.StartDate.getFullYear(),

            month,

            1

          ).getTime();

          sDate.setTime(newDate);

          var data = {

            TaskID: args.data.TaskID,

            StartDate: sDate,

          };

          this.isUpdated = true;

          this.ganttObj.updateRecordByID(data);

        }

      }

    }

  }


Sample: https://stackblitz.com/edit/angular-xvpu2t?file=app.component.ts


Regards,

Premkumar S



EF Eliseo Felcher April 5, 2022 07:48 AM UTC

Thank you! Exactly what I needed.


Have a good day,

EF



RP Ranjani Prabakaran Syncfusion Team April 5, 2022 08:50 AM UTC

Hi Eliseo,


Please get back to us if you need any further assistance.


Regards,


Ranjani


Loader.
Up arrow icon