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

Loading events from 1 month and earlier on Scheduler view

Asked by Tunc
1 year ago.

Hi,

I would like to load events dynamically as I scroll through scheduler from past 1 month and earlier. Right now scheduler shows events from around 1 month earlier but not more. Is there a way to achieve this? Just for the info, below settings are enabled.

dp.dynamicEventRendering = "Enabled";

dp.dynamicLoading = true;

Thanks!

Comment posted by Tunc
1 year ago.

Sorry not Gantt view but Scheduler view!

Answer posted by Dan Letecky [DayPilot]
1 year ago.

If you would like to load Scheduler events from the server during scrolling (this feature is called dynamic event loading), you need to do two things:

  1. Enable this feature using dynamicLoading: true (as you do).

  2. Load the actual event data from the server (or other data source) in the onScroll event handler.

You can find an example in the documentation:

<script>
  const dp = new DayPilot.Scheduler("dp", {
    dynamicLoading: true,
    onScroll: async (args) => {
    
      const start = args.viewport.start;
      const end = args.viewport.end;

      const {data} = await DayPilot.Http.get(`/events?start=${start}&end=${end}`);
      args.events = data;
      args.loaded();

    ),
    // ...
  });
  dp.init();

</script>

The data loading is set to asynchronous mode by default (args.async === true). It is necessary to call args.loaded() when the data is available.

You can also find more complex examples in the following tutorials. They which include a server side part (ASP.NET Core or PHP) and some additional explanation and performance tips:

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