In order to update the scheduler on the client side during a CallBack it is necessary to call Update() method.

ASP.NET WebForms

Update Type

public void Update(CallBackUpdateType updateType);

CallBackUpdateType is an enum with the following values:

  • Auto
  • EventsOnly
  • Full
  • None

Auto is the default value. It selects the update mode depending on values that were actually changed during the CallBack.

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).

Properties

Always updated (None, EventsOnly, Full):

  • ClientState
  • SelectedEvents
  • Message (UpdateWithMessage())

EventsOnly update

  • Events (DataSource)

Full update

  • StartDate
  • Days
  • CellDuration
  • CellGroupBy
  • CellWidth
  • ScrollX
  • ScrollY
  • Separators
  • Cells (BeforeCellRender)
  • Resources (incl. BeforeResHeaderRender)
  • Time Headers (BeforeTimeHeaderRender)
  • CornerHtml
  • CornerBackColor
  • RowHeaderColumns

Message

You can display custom message using UpdateWithMessage() method:

DayPilotScheduler1.UpdateWithMessage("Event moved");

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

Example 1: Sending a simple string

.aspx

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

Server-side code (.aspx.cs):

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

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

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

        DayPilotScheduler1.DataBind();

        Hashtable ht = new Hashtable();
        ht["message"] = "Event moved.";
        ht["id"] = e.Value;
        DayPilotScheduler1.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 + ")";
    }
}

ASP.NET MVC

Update Type

public void Update(CallBackUpdateType updateType);

CallBackUpdateType is an enum with the following values:

  • EventsOnly
  • Full
  • None

EventsOnly is the default value. It updates the events (Events property).

Full value reloads events, resources, cells and headers (including other selected properties, see below).

Properties

Always updated (None, EventsOnly, Full):

  • Message (UpdateWithMessage())

EventsOnly update

  • SelectedEvents
  • EventSortExpression
  • Events (DataSource)

Full update

  • StartDate
  • Days
  • CellDuration
  • CellGroupBy
  • CellWidth
  • ScrollX
  • ScrollY
  • Separators
  • Cells (BeforeCellRender)
  • Resources (incl. BeforeResHeaderRender)
  • Time Headers (BeforeTimeHeaderRender)
  • CornerHtml
  • CornerBackColor
  • ShowBaseTimeHeader
  • DynamicLoading
  • HourNameBackColor
  • ShowNonBusiness
  • BusinessBeginsHour
  • BusinessEndsHour
  • TreeEnabled
  • BackColor
  • NonBusinessBackColor
  • TimeFormat
  • WeekStarts

Message

You can display custom message using UpdateWithMessage() method:

UpdateWithMessage("Event moved");

The default update type is EventsOnly.

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

Example 1: Sending a simple string

MVC View

@Html.DayPilotScheduler("dps", new DayPilotSchedulerConfig {
  BackendUrl = ResolveUrl("~/Scheduler/Backend"),
  ...
  AfterRenderJavaScript = "afterRender(data, isCallBack)"
})

<script type="text/javascript">
  function afterRender(data) {
    if (data) {
         document.getElementById('messageDiv').innerHTML = data;
    }
  }
</script>

MVC Controller (Dps class)

protected override void OnEventResize(EventResizeArgs ea)
{
  new EventManager(Controller).EventMove(ea.Id, ea.NewStart, ea.NewEnd, ea.Resource);
  Update("Updated");
}

Example 2: Sending a dictionary

MVC View

@Html.DayPilotScheduler("dps", new DayPilotSchedulerConfig {
  BackendUrl = ResolveUrl("~/Scheduler/Backend"),
  ...
  AfterRenderJavaScript = "afterRender(data, isCallBack)"
})

<script type="text/javascript">
  function afterRender(data) {
    if (data) {
         document.getElementById('messageDiv').innerHTML = data.message;
    }
  }
</script>

MVC Controller (Dps class)

protected override void OnEventResize(EventResizeArgs ea)
{
  new EventManager(Controller).EventMove(ea.Id, ea.NewStart, ea.NewEnd, ea.Resource);

  Hashtable ht = new Hashtable();
  ht["message"] = "Event resized.";
  ht["id"] = e.Value;

  Update(ht);
}