The commandCallBack() method can be used to send custom command with custom data to the server side.

Typical Use

  • Reload the event data
  • Switch the visible time range
  • Refresh the control after changing the resources
  • Filtering the visible events

How It Works

When you invoke the commandCallBack() function on the client-side DayPilot Scheduler object, it will fire the Commandevent handler on the server-side using an AJAX call.

In the Command event handler you should call Update() after doing your work and reloading the events using DataBind().

See also: Update() method

Parameters

  • command (string) - custom command type string
  • data (any JavaScript object) - custom data that will be sent to the server-side Command handler

The data parameter will be translated into JsonData class - see also Sending custom data with CallBack.

Reference

ASP.NET WebForms

Example (switching to a specified year)

.aspx

<a href="javascript:dps1.commandCallBack('year', 2013);">Next</a>

.aspx.cs:

    protected void DayPilotScheduler1_Command(object sender, DayPilot.Web.Ui.Events.CommandEventArgs e)
    {
        switch (e.Command)
        {
            case "year":
                DayPilotScheduler1.StartDate = new DateTime((int)e.Data, 1, 1);
                DayPilotScheduler1.Days = Year.Days(DayPilotScheduler1.StartDate.Year);
                break;
            // ...
        }
        // ...
        DayPilotScheduler1.DataBind();
        DayPilotScheduler1.Update(CallBackUpdateType.Full);
    }

ASP.NET MVC

View

<a href="javascript:dps.commandCallBack('next');">Next</a>
<a href="javascript:dps.commandCallBack('previous');">Previous</a>

<a href="javascript:dps.commandCallBack('delete', { id: 123});">Delete Event with ID=123</a>

Controller (SchedulerController.cs)

class Dps : DayPilotScheduler
{

  protected override void OnCommand(CommandArgs e)
  {
      switch (e.Command)
      {
          case "refresh":
              UpdateWithMessage("Refreshed");
              break;
          case "next":
              StartDate = StartDate.AddYears(1);
              Days = Year.Days(StartDate);
              Update(CallBackUpdateType.Full);
              break;
          case "previous":
              StartDate = StartDate.AddYears(-1);
              Days = Year.Days(StartDate);
              Update(CallBackUpdateType.Full);
              break;
          case "this":
              StartDate = Year.First(DateTime.Today);
              Days = Year.Days(StartDate);
              Update(CallBackUpdateType.Full);
              break;
          case "delete":
              string id = (string)e.Data["id"];
              new EventManager(Controller).EventDelete(id);
              Update(CallBackUpdateType.EventsOnly);
              break;
      }
  }
}