Morning,
I have a project with a project calendar and I want to remove the calendar and adjust the default (27/7) calendar to all my tasks.
I use the following simple code:
var calMngr = gantt.cm.getCalendarManager(),
ProjNode = calMngr && calMngr.getNodeByCalendar(calMngr.getProjectCalendar());
//If the project calendar-node is found remove it!
ProjNode && ProjNode.remove();
//Adjust the default calendar
gantt.getTaskStore().adjustToCalendar();
but the line "gantt.getTaskStore().adjustToCalendar();" throws an error. The project calendar is still pointing to the original project calendar, which is marked 'destoyed'.
What is the best way to destroy the (custom) project-calendar and adjust the defaults?
Arno
There must be some project calendar assigned always. The gantt cannot live w/o it. So just removing won't work I think.
I would instead make a new calendar that fits your needs and set it as the project one:
// make some new calendar
var newCalendar = Ext.create('Gnt.data.Calendar', { Name : 'Foo' });
var cm = Ext.first('ganttpanel').crudManager.getCalendarManager();
// register it in the calendars store
cm.getRoot().appendChild({
calendar : newCalendar,
leaf : true
});
// make the calendar the project one
cm.setProjectCalendar(newCalendar);
After assigning a new calendar it will automatically realign tasks ..so no need to call adjustToCalendar.
And you can remove the old calendar too.