You can find the source for this example in the DayPilot package: Demo/Scheduler/Default.aspx.
This functionality is an example of refreshCallBack client-side method:
1. Use the BeforeTimeHeaderRender to change the headers. Include hyperlinks that call dps.refreshCallBack(newDate, newDays):
protected void DayPilotScheduler1_BeforeTimeHeaderRender(object sender, DayPilot.Web.Ui.Events.BeforeTimeHeaderRenderEventArgs e)
{
if (e.IsColGroup)
{
int days = (int) Math.Floor((e.End - e.Start).TotalDays);
DateTime outStart = DateTime.MinValue;
int outDays;
switch (DayPilotScheduler1.CellGroupBy)
{
case GroupByEnum.Hour: // day, switch to week
outStart = Week.FirstDayOfWeek(e.Start, DayOfWeek.Monday);
outDays = 7;
break;
case GroupByEnum.Day: // week, switch to month
outStart = new DateTime(e.Start.Year, e.Start.Month, 1);
outDays = DateTime.DaysInMonth(e.Start.Year, e.Start.Month);
break;
case GroupByEnum.Week: // month, switch to year
outStart = new DateTime(e.Start.Year, 1, 1);
outDays = DateTime.IsLeapYear(e.Start.Year) ? 366 : 365;
break;
case GroupByEnum.Month: // year, dont switch
outDays = 0;
break;
default:
throw new ArgumentOutOfRangeException();
}
if (days >= 1) // do not zoom into greater detail than one day
{
e.InnerHTML = String.Format("<a href="javascript:dps1.refreshCallBack(new Date(\"{0}\"), {1})" title="Zoom in">{2}</a>", JsDate.FormatDateTime(e.Start), days, e.InnerHTML);
}
if (outDays > 0) // do not zoom out if we see the whole year
{
e.InnerHTML += String.Format(" (<a title="Zoom out" href="javascript:dps1.refreshCallBack(new Date(\"{0}\"), {1})">up</a>)", JsDate.FormatDateTime(outStart), outDays);
}
}
}
2. Handle the Refresh event on the server side and update the StartDate and Days properties using the sent values:
protected void DayPilotScheduler1_Refresh(object sender, DayPilot.Web.Ui.Events.RefreshEventArgs e)
{
DayPilotScheduler1.StartDate = e.StartDate;
DayPilotScheduler1.Days = e.Days;
if (e.Days > 31) // year
{
DayPilotScheduler1.CellGroupBy = GroupByEnum.Month;
DayPilotScheduler1.CellDuration = 1440;
DayPilotScheduler1.CellWidth = 20;
}
else if (e.Days >= 28) // month
{
DayPilotScheduler1.CellGroupBy = GroupByEnum.Week;
DayPilotScheduler1.CellDuration = 1440;
DayPilotScheduler1.CellWidth = 30;
}
else if (e.Days > 1) // week
{
DayPilotScheduler1.CellGroupBy = GroupByEnum.Day;
DayPilotScheduler1.CellDuration = 60;
DayPilotScheduler1.CellWidth = 20;
}
else // day
{
DayPilotScheduler1.CellGroupBy = GroupByEnum.Hour;
DayPilotScheduler1.CellDuration = 15;
DayPilotScheduler1.CellWidth = 20;
}
// update DayPilotScheduler1.DataSource and call DayPilotScheduler1.DataBind() here
// ...
DayPilotScheduler1.Update();
}