CommandCallBack()

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 Command event 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.

Example (switching to a specified year)

Demo/Scheduler/Default.aspx:

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

Demo/Scheduler/Default.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);
    }

 Reference

DayPilot for ASP.NET WebForms, DayPilot for ASP.NET MVC, DayPilot for Java