Page 1 of 1

Clear project calendar

Posted: Wed Jan 12, 2022 11:43 am
by Arno Voerman

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 =,
ProjNode = calMngr && calMngr.getNodeByCalendar(calMngr.getProjectCalendar());

//If the project calendar-node is found remove it!
ProjNode && ProjNode.remove();

//Adjust the default calendar

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?


Re: Clear project calendar

Posted: Wed Jan 12, 2022 2:05 pm
by arcady

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('', { Name : 'Foo' });

var cm = Ext.first('ganttpanel').crudManager.getCalendarManager();

// register it in the calendars store
    calendar : newCalendar,
    leaf     : true

// make the calendar the project one

After assigning a new calendar it will automatically realign tasks no need to call adjustToCalendar.
And you can remove the old calendar too.

Re: Clear project calendar

Posted: Wed Jan 12, 2022 3:18 pm
by Arno Voerman

OK. this helps. I just hoped the standard calendar was automatically added.