search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Rolling schedule possible ?

Asked by Patrik
4 years ago.

Hi.

Is there any way to have an rolling schedule . i.e. a 24 hour window that updates in real time ?
I have looked into manual timelines , but they only seems to have an visual impact.
The important properties seems to be "startDate" and "days", is there any way to continuously update the
schedule by moving the startDate ahead ?

Answer posted by Dan Letecky [DayPilot]
4 years ago.

The generated timeline (scale !== "Manual") starts at 00:00 on the date specified using startDate. If you want to shift the start by a smaller unit you will need to hide selected time cells (https://doc.daypilot.org/scheduler/hiding-time-columns/) or generate the timeline manually (https://doc.daypilot.org/scheduler/timeline/).

Another option would be to render a larger date range and scroll the viewport to the current time using scrollTo() method regularly:
https://api.daypilot.org/daypilot-scheduler-scrollto/

Comment posted by Patrik
4 years ago.

Hi Dan, thanks for the reply

Custom timeline may be the way to go , assuming it can be updated continuously,

Following the example in your URL , setting scale to "Manual" and creating a custom timeline like this ( calling it from ngAfterViewInit).

setTimeline() {
this.scheduler.control.timeline = [];

var startDate: DayPilot.Date = new DayPilot.Date(this.scheduler.control.startDate);

for (var i = 0; i < 24; i++) {
startDate = new DayPilot.Date(this.scheduler.control.startDate).addHours(i);
for (var j = 0; j < 6; j++) {
var cell = { 'start': null, 'end' : null};
cell.start = startDate.addMinutes(j * 10);
cell.end = cell.start.addMinutes(10);
this.scheduler.control.timeline.push(cell);
}
}

this.scheduler.control.init();
}

This results in a blank (empty) header , it also trows an exception

ERROR TypeError: Cannot read property 'length' of null
at DayPilot.Scheduler.Mg (webpack-internal:///./node_modules/daypilot-pro-angular/daypilot-angular.min.js:24)
at DayPilot.Scheduler.fc (webpack-internal:///./node_modules/daypilot-pro-angular/daypilot-angular.min.js:24)
at DayPilot.Scheduler.Bn (webpack-internal:///./node_modules/daypilot-pro-angular/daypilot-angular.min.js:32)
at DayPilot.Scheduler.init (webpack-internal:///./node_modules/daypilot-pro-angular/daypilot-angular.min.js:32)
at t.ngAfterViewInit (webpack-internal:///./node_modules/daypilot-pro-angular/daypilot-angular.min.js:33)
at callProviderLifecycles (webpack-internal:///./node_modules/@angular/core/esm5/core.js:12964)
at callElementProvidersLifecycles (webpack-internal:///./node_modules/@angular/core/esm5/core.js:12931)
at callLifecycleHooksChildrenFirst (webpack-internal:///./node_modules/@angular/core/esm5/core.js:12914)
at checkAndUpdateView (webpack-internal:///./node_modules/@angular/core/esm5/core.js:14069)
at callViewAction (webpack-internal:///./node_modules/@angular/core/esm5/core.js:14411)

What am I missing ?, I am using version 2019.4.4089.

Comment posted by Dan Letecky [DayPilot]
4 years ago.

Use update() instead of init(). The DayPilot.Scheduler instance is initialized automatically in Angular.

But you may want to use the "config" object for the timeline. This will ensure the changes are applied automatically.

Normally you'd want to keep all the properties in the config object ("config" attribute) and only use the direct api for "config.resources" and "events" as they become bigger (see https://doc.daypilot.org/scheduler/angular-performance/).

Comment posted by Patrik
4 years ago.

update() instead of Init() makes no difference.

Comment posted by Dan Letecky [DayPilot]
4 years ago.

It looks like it doesn't reach setTimeline() at all. The problem is with missing "timeline" property in the config. Try adding:

timeline:[]

In the latest sandbox build, this should be fixed and the Scheduler will accept an undefined timeline.

Comment posted by Patrik
4 years ago.

Thanks Dan, got it working perfectly !

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.