DayPilot.Scheduler.onScroll

The onScroll event is fired whenever the Scheduler grid scrollbar position changes (when dynamic event loading is enabled).

Notes:

  • The only actions allowed in onScroll are to set the args properties and call args.loaded(). Do not change any Scheduler properties in onScroll. Do not call update() method or other methods that refresh the Scheduler [like rows.filter() or rows.load()]. 
  • Angular: Do not set [events] attribute if dynamic event loading is enabled. In combination with args.clearEvents = false, this would cause an infinite loop.
  • React: Do not set events property if dynamic event loading is enabled. Do not save the events loaded in onScroll to events property. This would cause an infinite loop.

Parameters

  • args.viewport.start (DayPilot.Date) - readonly viewport start date/time
  • args.viewport.end (DayPilot.Date) - readonly viewport end date/tiem
  • args.viewport.resources (array of resource IDs - strings or numbers) - readonly list of viewport resources
  • args.async (boolean) - if set to true, the scheduler won't be updated until args.loaded() is called - use for async data loading; the default value is true (since 2020.1.4276)
  • args.events - array of event data objects (structure defined in DayPilot.Event.data)
  • args.remove - events to be removed (array of string | number values); experimental - use args.clearEvents = true instead
  • args.clearEvents (boolean) - whether to clear all existing events before loading the new ones from args.events; the default value is true (since 2019.4.4101)
  • args.loaded() - performs an async update

See Also

Example

dp.dynamicLoading = true;
dp.onScroll = function(args) {
    args.async = true;
    
    // simulating slow server-side load
    setTimeout(function() {
        
        var events = [];

        // generate 10 new events
        for (var i = 0; i < 10; i++) {
            var duration = Math.floor(Math.random() * 6) + 1; // 1 to 6
            var startOffset = Math.floor(Math.random() * 6) + 1; // 1 to 6

            var start = args.viewport.start.addDays(startOffset);
            var end = start.addDays(duration);

            var e = {
                start: start,
                end: end,
                id: DayPilot.guid(),
                resource: "A",
                text: "Event"
            };
            
            events.push(e);
        }
    
        args.events = events;
        args.loaded();
    }, 500);        
};