Page 1 of 1

[REACT] [Gantt] New task end date is not getting defaulted from parent row

Posted: Sun May 28, 2023 9:45 am
by sprabhu

Hi,
When we add a new task (new task below) the start date gets defaulted from the parent row but the end date is not. Seems its take the duration from the selected row and calculates the end date based on 'Start Date + duration'
Can we make a change here so that task end date is in sync with parent end date.
Please refer to the recording using the link below:
https://frontrol-my.sharepoint.com/:v:/p/cgupta/EcjPGc4E84NJpg0-LWeR67sBJKKhSGFmK5a7Uh0Z6NfWTQ?e=3e9I7u
As per the recording, the expected behaviour would be: the 'New task 1' should also have Finish date as Mar 20, 2019(as as of parent task 'Launch SaaS Product')

I am using advanced example: link below
https://bryntum.com/products/gantt/examples/advanced/


Re: [REACT] [Gantt] New task end date is not getting defaulted from parent row

Posted: Mon May 29, 2023 8:23 am
by tasnim

Hi,

You could achieve by listening to https://bryntum.com/products/gantt/docs/api/Gantt/data/TaskStore#event-beforeAdd event
and apply the logic

// using a count variable to silent the initial add
let count = 0;
new Gantt({
	project : {
		taskStore : {
			listeners : {
				beforeAdd({ parent, records }) {
					if (count > 0) {
						records[0].duration = parent.duration;
					} else {
						count++;
					}
				}
			}
		}
	}
})

Hope this will help


Re: [REACT] [Gantt] New task end date is not getting defaulted from parent row

Posted: Tue Jun 13, 2023 4:51 pm
by sprabhu

thanks for this, we can close this one.