Premium support for our pure JavaScript UI components


Post by jit@flowit.dk »

Thanks for the suggestion, @acady.
What exactly is the "business" calendar? Will it affect Duration if a task spans weekends? Or will every day between StartDate and EndDate count ?

Best regards
Jimmy Thomsen


Post by arcady »

What exactly is the "business" calendar?

The calendar specifies working time Mon-Fri 08:00-12:00, 13:00-17:00.
And changing hoursPerDay to 8 results the Gantt considers 1 day equal 8 hours.

So, for example, a 1 day duration task will have start date 2024-06-19 08:00 and end date 2024-06-19 17:00. So in UI both start and end will display the same 2024-06-19 value.

Will it affect Duration if a task spans weekends? Or will every day between StartDate and EndDate count ?

It depends on a calendar. That specific calendar treats Sat and Sun as non-working days.
So if a duration is calculated between two dates it will collect only working periods of time.


Post by jit@flowit.dk »

@arcady Is there a built-in calendar that include all days as working days ?
Setting hoursPerDay alone makes gantt behave strange. If a task is spanning 10 days and we set hoursPerDay to 8, it will then show the task as spanning only 3,33 days in the gantt view. This doesn't happen when we set the calendar. But we need all days of the week to count as working days.

Best regards
Jimmy Thomsen


Post by arcady »

@arcady Is there a built-in calendar that include all days as working days ?

We have a built-in calendar but it uses 24hrs/day availability which doesn't match your expectations.

But it's easy to make such calendar instead of the code I suggested above you can use:

gantt.project.calendar = '8hrs'
gantt.project.hoursPerDay = 8
gantt.calendarManagerStore.add({
    id        : '8hrs',
    name      : 'Sun-Mon 8h/day',
    intervals : [
        {
            recurrentStartDate : 'at 12:00',
            recurrentEndDate   : 'at 13:00',
            isWorking          : false
        },
        {
            recurrentStartDate : 'at 17:00',
            recurrentEndDate   : 'at 08:00',
            isWorking          : false
        }
    ]
});

Setting hoursPerDay alone makes gantt behave strange. If a task is spanning 10 days and we set hoursPerDay to 8, it will then show the task as spanning only 3,33 days in the gantt view. This doesn't happen when we set the calendar. But we need all days of the week to count as working days.

Yes the config value should be adjusted to match the project calendar. So we set it to 8 and provide the calendar that has 8h/day availability.


Post by jit@flowit.dk »

Very helpful, @arcady - thank you!

All tasks now assumes a start time of 08:00 and an end time of 17:00.
However, dragging a task on the time line or resizing a task, results in the timestamps not being preserved, and I guess the new timestamps depend on the active viewpreset's time resolution. But we need to preserve timestamps - one way or another. Do you have any suggestions? How do we force the start date to YYYY-MM-DD 08:00 and the end date to YYYY-MM-DD 17:00 ?

Also, the TypeScript definition for gantt.project.calendar does not accept strings, and gantt.calendarManagerStore doesn't even exist. We would appreciate if these bugs could be fixed so we don't have to cast things to any, as this could potentially hide breaking changes to the API.

Best regards
Jimmy Thomsen


Post by alex.l »

Hi Jimmy,

For taskResize, you could use timeResolution = 1 day, as you mentioned. You need to setup ViewPresets as you need, see https://bryntum.com/products/gantt/docs/api/Scheduler/preset/PresetManager , it should make that you want.
For taskEdit it should be working like that out of the box, I tested in our demos, just used 'business' calendar for projectModel.

Please test it and let us know if you faced any problems.

Also, the TypeScript definition for gantt.project.calendar does not accept strings, and gantt.calendarManagerStore doesn't even exist. We would appreciate if these bugs could be fixed so we don't have to cast things to any, as this could potentially hide breaking changes to the API.

Your right, I've opened a ticket to fix that https://github.com/bryntum/support/issues/9433
For now you have to use //@ts-ignore to go forward, I hope it's ok for a temp workaround.

All the best,
Alex Lazarev

How to ask for help? Please read our Support Policy

We do not write the code in bounds of forum support. If you need help with development, contact us via bryntum.com/services


Post by jit@flowit.dk »

Thanks @alex.l

For taskResize, you could use timeResolution = 1 day, as you mentioned.

Awesome - it works for resizing. It does not when moving the task though:

Bryntum-2024-06-25-002.png
Bryntum-2024-06-25-002.png (28.43 KiB) Viewed 314 times

The startDate snaps to midnight rather than remaining at 08:00. The endDate does remain at 17:00.
I tried enabling and disabling snap but it doesn't change anything. Any suggestions ?

Your right, I've opened a ticket to fix that

Thanks :-)

Best regards
Jimmy Thomsen


Post by jit@flowit.dk »

Oh, I just found snapRelativeToEventStartDate which seems to fix the problem related to dragging the task on the time line. I think we are all set. Thanks guys :-)

Best regards
Jimmy Thomsen


Post by alex.l »

Glad to hear you figured out :) Good luck!

All the best,
Alex Lazarev

How to ask for help? Please read our Support Policy

We do not write the code in bounds of forum support. If you need help with development, contact us via bryntum.com/services


Post by mats »

Re. calendarManagerStore, use instead:

gantt.project.calendarManagerStore

Post Reply