Calendar: View Types

The ViewType property specifies how the Calendar columns are generated:

  • Day: One column will be displayed, showing StartDate.
  • WorkWeek: Five columns will be displayed, showing work days from a week to which StartDate belongs.
  • Week: Seven columns will be displayed, showing a week to which StartDate belongs.
  • Days: A custom number of columns will be displayed, starting with StartDate. The number of columns is determined by the Days property.
  • Resources: A custom set of columns will be displayed. The total number, dates, resources, and title of the columns is specified using Resources property.

See also

Example 1: Manually setting the columns in the view

        <%=Html.DayPilotCalendar("dpc", new DayPilotCalendarConfig
                                                       {
                                                           BackendUrl = ResolveUrl("~/Calendar/Backend"),
                                                           ViewType = DayPilot.Web.Mvc.Enums.Calendar.ViewType.Resources,
                                                           Columns = new ColumnCollection
                                                                         {
                                                                             new Column("Column A", "A", DateTime.Today),
                                                                             new Column("Column B", "B", DateTime.Today)
                                                                         }
            })%>

Example 2: Generating the columns in the backend controller

View

        <%=Html.DayPilotCalendar("dpc", new DayPilotCalendarConfig
                                                       {
                                                           BackendUrl = ResolveUrl("~/Calendar/Backend"),
                                                           ViewType = DayPilot.Web.Mvc.Enums.Calendar.ViewType.Resources
            })%>

Controller

    public class CalendarController : Controller
    {
        public ActionResult Backend()
        {
            return new Dpc().CallBack(this);
        }

        public class Dpc : DayPilotCalendar
        {

            protected override void OnInit(InitArgs initArgs)
            {
                UpdateWithMessage("Welcome!", CallBackUpdateType.Full);

                Columns.Clear();
                Columns.Add("Column A", "A", DateTime.Today);
                Columns.Add("Column B", "B", DateTime.Today);
                    
            }

            protected override void OnFinish()
            {
                // only load the data if an update was requested by an Update() call
                if (UpdateType == CallBackUpdateType.None)
                {
                    return;
                }

                // this select is a really bad example, no where clause
                Events = new EventManager(Controller).Data.AsEnumerable();

                // no need to override the field names, we are using the default ones
                /*
                DataStartField = "start";
                DataEndField = "end";
                DataTextField = "name";
                DataIdField = "id";
                DataResourceField = "resource";
                 */
                DataAllDayField = "allday";
                DataTagFields = "id, name";
            }
        }

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