Premium support for our pure JavaScript UI components


Post by quandarycg »

In gantt v.4.3.7, we are trying to add a subask with duration of 1 day and start date matching the parent. I've tried the following based on this post: viewtopic.php?p=94027#p94027

menu: {
   customSub: {
       text: 'Add Subtask',
       icon: "b-fa-arrow-down",
       onItem: async ({taskRecord}) => {
           const task = await gantt.addSubtask(taskRecord);
           task.name = 'Test'; // or whatever you need
           task.duration = 1;
           task.durationUnit = "day";
           task.startDate = taskRecord.startDate
           gantt.project.commitAsync();
       }
   },
}

This creates a subtask, but it does none of the specified values are set. Am I doing something wrong?


Post by marcio »

Hey quandarycg,

Where did you put that piece of code inside your configuration?? First of all, we recommend updating to the latest version of the Bryntum suite, also, are you able to reproduce that behavior in our demos?? We need more information about how is the component set up to assist you better.

Best regards,
Márcio


Post by quandarycg »

Updating to the latest version breaks some other functionality we have, so we'd rather not at this point if possible.

Here is the hierarchy:

gantt = new bryntum.gantt.Gantt({
   features: {
      taskMenu: {
         items: {
            add: {
               menu: {
                  customSub: {
                     text: 'Add Subtask',
                     icon: "b-fa-arrow-down",
                     onItem: async ({source:gantt, taskRecord}) => {
                         console.log("TASK ADD TEST")
                         const task = await gantt.addSubtask(taskRecord);
                         task.name = 'Test'; // or whatever you need
                         task.duration = 1;
                         task.durationUnit = "day";
                         task.startDate = taskRecord.startDate
                         gantt.project.commitAsync();
                     }
                  }
               }
            }
         }
      }
   }
}

Essentially, we are trying to add a subtask with custom values. If it gets added with the default values, it messes up some logic we have tied to the Parent task.


Post by marcio »

Hey quandarycg,

We have that snippet working just fine on the newest version of Bryntum, as you'll be able to see in the video attached.

Attachments
Bryntum Gantt - Basic Gantt chart demo - 29 September 2022.mp4
(250.19 KiB) Downloaded 23 times

Best regards,
Márcio


Post Reply