Premium support for our pure JavaScript UI components


Post 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/


Post 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


Post by sprabhu »

thanks for this, we can close this one.


Post Reply