Update() Method (CallBack Update)

What to update

In DayPilot Pro 5.0, the Update() method has a new parameter that specifies what should be updated:

public void Update(CallBackUpdateType updateType);

CallBackUpdateType is an enum with the following values:

  • None
  • EventsOnly
  • Full

EventsOnly is the default value. Full value reloads both events and headers (including the upper-left corner, see also forums.daypilot.org/Topic.aspx/561/how_to_update_the_content_of_top_left_corner_cell_on_schedul).

Updateable properties

Properties that can be changed during full update:

  • DataSource
  • StartDate
  • Days
  • CellDuration
  • CellGroupBy
  • CellWidth

Sending custom data to the client

It is possible to send a custom data from the CallBack event handler back to the client. This will allow showing custom messages after the event was handled.

callback-data.png

Example 1: Sending a simple string

Server-side code (.aspx.cs):

    protected void DayPilotScheduler1_TimeRangeSelected(object sender, TimeRangeSelectedEventArgs e)
    {
        // ... update database

        DayPilotScheduler1.DataBind();
        DayPilotScheduler1.Update("New event created.");
    }

Server-side template (.aspx):

    <daypilot:daypilotscheduler id="DayPilotScheduler1" runat="server"          ...         AfterRenderJavaScript="afterRender(data);"         ></daypilot:daypilotscheduler>

Client-side code (.aspx):

function afterRender(data) {
    if (data) {
         document.getElementById('messageDiv').innerHTML = data;
    }
}

Example 2: Sending a dictionary

Server-side code (.aspx.cs):

    protected void DayPilotScheduler1_TimeRangeSelected(object sender, TimeRangeSelectedEventArgs e)
    {
        // ... update database

        DayPilotCalendar1.DataBind();

        Hashtable ht = new Hashtable();
        ht["message"] = "Event moved.";
        ht["id"] = e.Value;
        DayPilotCalendar1.Update(ht);
    }

Server-side template (.aspx):

    <daypilot:daypilotscheduler id="DayPilotScheduler1" runat="server" 
        ...
        AfterRenderJavaScript="afterRender(data);"         ></daypilot:daypilotscheduler>

Client-side code (.aspx):

function afterRender(data) {
    if (data) {
        document.getElementById('messageDiv').innerHTML = data.message + " (id " + data.id + ")";
    }
}

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