The Monthly Calendar supports automatic event reloading (in specified intervals).

AutoRefresh is disabled by default. You can enable it using autoRefreshEnabled property.

Configuration properties:

  • autoRefreshEnabled (bool)
  • autoRefreshInterval (int) - number of seconds between automatic reloads
  • autoRefreshMaxCount(int) - maximum number of automatic reloads
  • autoRefreshCommand(string) - a command value that will be passed to Command event when requesting a reload

JavaScript

If enabled using autoRefreshEnabled property, it will fire onAutoRefresh event in the specified intervals.

dp.autoRefreshInterval = 10; 
dp.autoRefreshMaxCount = 10;
dp.autoRefreshEnabled = true;

dp.onAutoRefresh = function(args) { 
  dp.events.load("/getEvents"); 
};

ASP.NET WebForms

If enabled, AutoRefresh will fire Command event on the server side with the value of AutoRefreshCommand as the command name.

.aspx

<DayPilot:DayPilotMonth 
  ID="DayPilotMonth1" 
  runat="server" 
  ...
  OnCommand="DayPilotMonthr1_Command" 
  AutoRefreshEnabled="true"
  AutoRefreshInterval="10"
  AutoRefreshMaxCount="12"
  />

.aspx.cs

protected void DayPilotMonth1_Command(object sender, CommandEventArgs e)
{
  switch (e.Command)
  {
      case "refresh":
          setDataSourceAndBind();
          DayPilotCalendar1.DataBind();
          DayPilotCalendar1.UpdateWithMessage("Events refreshed automatically");
          break;
  }
}

ASP.NET MVC

View

@Html.DayPilotMonth("dpm", new DayPilotMonthConfig()
{
  BackendUrl = ResolveUrl("~/Month/Backend"),
  ...
  AutoRefreshEnabled = true,
  AutoRefreshInterval = 10,
  AutoRefreshMaxCount = 5
})

Controller

protected override void OnCommand(CommandArgs e)
{
  switch (e.Command)
  {
      case "refresh":
          UpdateWithMessage("Refreshed");
          break;
  }
}

protected override void OnFinish()
{
  // only load the data if an update was requested by an Update() call
  if (UpdateType == CallBackUpdateType.None)
  {
      return;
  }

  Events = new EventManager(Controller).FilteredData(VisibleStart, VisibleEnd).AsEnumerable();  // your method

  DataStartField = "start";
  DataEndField = "end";
  DataTextField = "text";
  DataIdField = "id";
}

Demo

JavaScript

AutoRefresh is not available for DayPilot Pro for JavaScript.