Dynamically setting startDate and endDate for the scheduler based upon events

Show cool things you have done with our products
Post Reply
User avatar
KevinMonk
Posts: 2
Joined: Mon Sep 09, 2019 10:28 am

Dynamically setting startDate and endDate for the scheduler based upon events

Post by KevinMonk » Mon Sep 09, 2019 11:51 am

Hi. I'm evaluating your product for use in a SaaS project. I'm currently within the free trial period. Is there an example of how to dynamically set the startDate and endDate for a scheduler based upon the events resource array? THe documentation hints at it.

For example, if I comment out setting startDate and endDate in the React Simple Example (lines 97 and 98 of examples/react/simple/src/Main.js), I would expect autoAdjustTimeAxis to kick in as it's true by default; but it doesn't and instead shows the current time + 24 hours?

Code: Select all

                <BryntumScheduler
                    ref={'scheduler'}

                    // Make grid grow to fit rows
                    autoHeight={true}

                    // Initial row height
                    barMargin={this.state.barMargin}

                    // startDate={new Date(2017, 1, 7, 8)}
                    // endDate={new Date(2017, 1, 7, 18)}


User avatar
mats
Core Developer
Core Developer
Posts: 14554
Joined: Sat Dec 19, 2009 11:41 pm
Location: Sweden
Contact:

Re: Dynamically setting startDate and endDate for the scheduler based upon events

Post by mats » Mon Sep 09, 2019 12:15 pm

You can set 'startDate' and 'endDate' anytime, as you can see in our API docs. So after you load your data you can ask the eventStore for the date range in the contents and just set it yourself. Docs:

https://bryntum.com/docs/scheduler/#Scheduler/view/mixin/TimelineZoomable#function-setTimeSpan

https://bryntum.com/docs/scheduler/#Scheduler/data/mixin/EventStoreMixin#function-getTotalTimeSpan
Tired of debugging javascript errors in web applications? Try our new error logging service RootCause, or read more on the Sencha blog

@bryntum
Facebook
API documentation

User avatar
KevinMonk
Posts: 2
Joined: Mon Sep 09, 2019 10:28 am

Re: Dynamically setting startDate and endDate for the scheduler based upon events

Post by KevinMonk » Mon Sep 09, 2019 1:31 pm

Thanks. Will try that. What's the purpose of autoAdjustTimeAxis then? I'm struggling to understand what effect it has.

User avatar
sergey.maltsev
Core Developer
Core Developer
Posts: 56
Joined: Mon Dec 24, 2018 9:15 am

Re: Dynamically setting startDate and endDate for the scheduler based upon events

Post by sergey.maltsev » Mon Sep 09, 2019 2:36 pm

Hi, KevinMonk!

When autoAdjustTimeAxis is false scheduler uses the exact configured dates, by keeping it as true it adapts to the used viewpreset.
For example showing a full week even if configured with a Wednesday as the startdate.
Or if viewpreset configured with days and startdate is at 08:00, it will show from the start of the day instead to keep ticks whole.

It sets autoAdjust on TimeAxis
https://www.bryntum.com/docs/scheduler/#Scheduler/data/TimeAxis#config-autoAdjust

Post Reply