Our pure JavaScript Scheduler component


Post by sbindiger »

I've implemented recurring time ranges for weekly time slots, but they only start from the current date forward.

How can I have it show for past weeks as well?

let resourceTimeRange = {
                            id: id,
                            resourceId: resourceId,
                            startDate: new Date(day.getFullYear(), day.getMonth(), day.getDate(), startHour, startMinute),
                            duration: 15,
                            durationUnit: "minutes",
                            style: 'background: rgba(239, 83, 80, .5)',
                            recurrenceRule : 'FREQ=WEEKLY'
                        };
 

Post by marcio »

Hey,

As you'll be able to see here https://www.bryntum.com/docs/scheduler/api/Scheduler/feature/TimeRanges

Each time range is represented by an instance of TimeSpan

And checking the TimeSpan model here https://www.bryntum.com/docs/scheduler/api/Scheduler/model/TimeSpan
You will check that you need to have a startDate set, to achieve what you want, you can set a startDate earlier than today, and with that, you will have the recurrent time range for earlier periods.

let resourceTimeRange = {
                            id: id,
                            resourceId: resourceId,
                            // set the startDate from a year than the "day" object
                            startDate: new Date((day.getFullYear() - 1), day.getMonth(), day.getDate(), startHour, startMinute),
                            duration: 15,
                            durationUnit: "minutes",
                            style: 'background: rgba(239, 83, 80, .5)',
                            recurrenceRule : 'FREQ=WEEKLY'
                        };
 

Best regards,
Márcio


Post by sbindiger »

Um... How did I miss that...

Thanks so much!


Post Reply