Views
22 Jun 201614 minutes to read
The number of days and its associated appointments are usually grouped together in Scheduler to organize different views. The available view options in Scheduler are as follows,
- Day
- Week
- Workweek
- Month
- Custom View
- Agenda
- Timeline View
Usually these view options are displayed as a toolbar in the date-header section of the Schedule control. The items within the views toolbar can be added/removed based on the value passed to the Views
property.
By default, the Schedule control’s active view is Week view. Also, it is possible to change the active view of the Scheduler by setting CurrentView
option with the required view name as depicted below.
@using MyProject.Models; // Here MyProject defines your project name to access the model class
@{
<!-- Datasource for Appointments -->
List<ScheduleFields> Appoint = new List<ScheduleFields>();
Appoint.Add(new ScheduleFields { Id = "1", Subject = "Meeting", StartTime = new DateTime(2015, 11, 10, 10, 00, 00), EndTime = new DateTime(2015, 11, 10, 11, 00, 00), Description = "", AllDay = false, Recurrence = false, RecurrenceRule = "" });
}
@{List<string> view = new List<string>() { "Day", "Week", "WorkWeek", "Month" };}
@(Html.EJ().Schedule("Schedule1")
.Width("100%")
.Height("525px")
.Views(view)
.CurrentView(CurrentView.Week)
.AppointmentSettings(fields => fields.Datasource(Appoint)
.Id("Id")
.Subject("Subject")
.StartTime("StartTime")
.EndTime("EndTime")
.AllDay("AllDay")
.Recurrence("Recurrence")
.RecurrenceRule("RecurrenceRule"))
)
NOTE
The CurrentView property accepts Enum value of
CurrentView.<ViewName>
.
Day
It represents a single day Scheduler view (single date display) with all its related appointments.
@using MyProject.Models; // Here MyProject defines your project name to access the model class
@{
<!-- Datasource for Appointments -->
List<ScheduleFields> Appoint = new List<ScheduleFields>();
Appoint.Add(new ScheduleFields { Id = "1", Subject = "Meeting", StartTime = new DateTime(2015, 11, 10, 10, 00, 00), EndTime = new DateTime(2015, 11, 10, 11, 00, 00), Description = "", AllDay = false, Recurrence = false, RecurrenceRule = "" });
}
@(Html.EJ().Schedule("Schedule1")
.Width("100%")
.Height("525px")
.CurrentView(CurrentView.Day)
.AppointmentSettings(fields => fields.Datasource(Appoint)
.Id("Id")
.Subject("Subject")
.StartTime("StartTime")
.EndTime("EndTime")
.AllDay("AllDay")
.Recurrence("Recurrence")
.RecurrenceRule("RecurrenceRule"))
)
Week
It’s a view displaying a count of 7 days (from Sunday to Saturday) with all its related appointments. The first day of the week can be changed using the FirstDayOfWeek
API which accepts either the integer
(Sunday=0, Monday=1, Tuesday=2, etc) or string
(“Sunday”, “Monday”, etc) or DayOfWeek
enum type value. The default value of this FirstDayOfWeek depends on the current culture (language) used in the Scheduler.
@using MyProject.Models; // Here MyProject defines your project name to access the model class
@{
<!-- Datasource for Appointments -->
List<ScheduleFields> Appoint = new List<ScheduleFields>();
Appoint.Add(new ScheduleFields { Id = "1", Subject = "Meeting", StartTime = new DateTime(2015, 11, 10, 10, 00, 00), EndTime = new DateTime(2015, 11, 10, 11, 00, 00), Description = "", AllDay = false, Recurrence = false, RecurrenceRule = "" });
}
@(Html.EJ().Schedule("Schedule1")
.Width("100%")
.Height("525px")
.CurrentView(CurrentView.Week)
.FirstDayOfWeek(DayOfWeek.Monday)
.AppointmentSettings(fields => fields.Datasource(Appoint)
.Id("Id")
.Subject("Subject")
.StartTime("StartTime")
.EndTime("EndTime")
.AllDay("AllDay")
.Recurrence("Recurrence")
.RecurrenceRule("RecurrenceRule"))
)
Work Week
Work week view displays the working days of the week (count of 5 days) and its associated appointments. It is also possible to customize the days to be displayed in the work week view using WorkWeek
API which accepts the string array such as [“Monday”, “Tuesday”, “Wednesday”, “Thursday” and “Friday”]. By default, it renders from Monday to Friday (5 days).
@using MyProject.Models; // Here MyProject defines your project name to access the model class
@{
<!-- Datasource for Appointments -->
List<ScheduleFields> Appoint = new List<ScheduleFields>();
Appoint.Add(new ScheduleFields { Id = "1", Subject = "Meeting", StartTime = new DateTime(2015, 11, 10, 10, 00, 00), EndTime = new DateTime(2015, 11, 10, 11, 00, 00), Description = "", AllDay = false, Recurrence = false, RecurrenceRule = "" });
}
@{List<string> workWeek = new List<string>() { "Monday", "Tuesday" ,"Wednesday", "Friday", "Saturday" };}
@(Html.EJ().Schedule("Schedule1")
.Width("100%")
.Height("525px")
.CurrentView(CurrentView.Workweek)
.WorkWeek(workWeek)
.AppointmentSettings(fields => fields.Datasource(Appoint)
.Id("Id")
.Subject("Subject")
.StartTime("StartTime")
.EndTime("EndTime")
.AllDay("AllDay")
.Recurrence("Recurrence")
.RecurrenceRule("RecurrenceRule"))
)
Month
Month view displays the entire days of a particular month and all its related appointments. An alternative way to navigate to a particular date in a day view directly from Month view, clicking on the appropriate month cell date header will do so. If the week date range column is clicked, it will navigate to the corresponding week view.
The next and previous month date cells in the Month view can be shown/hidden on the Scheduler using ShowNextPrevMonth
property by setting it to false.
For example – To set the Month view as current view in Scheduler and to hide the other month days in it, refer the below code example.
@using MyProject.Models; // Here MyProject defines your project name to access the model class
@{
<!-- Datasource for Appointments -->
List<ScheduleFields> Appoint = new List<ScheduleFields>();
Appoint.Add(new ScheduleFields { Id = "1", Subject = "Meeting", StartTime = new DateTime(2015, 11, 10, 10, 00, 00), EndTime = new DateTime(2015, 11, 10, 11, 00, 00), Description = "", AllDay = false, Recurrence = false, RecurrenceRule = "" });
}
@(Html.EJ().Schedule("Schedule1")
.Width("100%")
.Height("525px")
.CurrentView(CurrentView.Month)
.ShowNextPrevMonth(false)
.AppointmentSettings(fields => fields.Datasource(Appoint)
.Id("Id")
.Subject("Subject")
.StartTime("StartTime")
.EndTime("EndTime")
.AllDay("AllDay")
.Recurrence("Recurrence")
.RecurrenceRule("RecurrenceRule"))
)
NOTE
An appointment directly created in Month view will be considered as an all-day appointment.
Customizing number of days (Custom View)
The Scheduler can be displayed with the user-specified date ranges, such as 4 days or any specific date ranges instead of default view options, by making use of the RenderDates
property. This property includes two sub properties namely Start and End, which accepts the date object or date value in string format to specify the date range.
To display the custom view option in the toolbar-like view options in the scheduler header area, add the CustomView
value to the views property array collection as shown below.
@using MyProject.Models; // Here MyProject defines your project name to access the model class
@{
<!-- Datasource for Appointments -->
List<ScheduleFields> Appoint = new List<ScheduleFields>();
Appoint.Add(new ScheduleFields { Id = "1", Subject = "Meeting", StartTime = new DateTime(2015, 11, 10, 10, 00, 00), EndTime = new DateTime(2015, 11, 10, 11, 00, 00), Description = "", AllDay = false, Recurrence = false, RecurrenceRule = "" });
}
@{List<string> view = new List<string>() { "Day", "Week", "WorkWeek", "Month", "CustomView" };}
@(Html.EJ().Schedule("Schedule1")
.Width("100%")
.Height("525px")
.CurrentDate(new DateTime(2014, 5, 2))
.Views(view)
.CurrentView(CurrentView.CustomView)
.RenderDates(dt => dt.Start("5/01/2014").End("5/06/2014"))
.AppointmentSettings(fields => fields.Datasource(Appoint)
.Id("Id")
.Subject("Subject")
.StartTime("StartTime")
.EndTime("EndTime")
.AllDay("AllDay")
.Recurrence("Recurrence")
.RecurrenceRule("RecurrenceRule"))
)
When the date difference between the provided start and end date is greater than 7, then the month-like view will get displayed in Vertical Scheduler mode - whereas with the date difference less than 7 days displays the Scheduler with exact count of the specified days.
NOTE
When the
CurrentDate
property of Scheduler is set with a date, that lies beyond the specified custom date range - then the Scheduler navigates to the current date with the mentioned date differences.
Agenda
This View option lists out the appointments in a grid-like view for the next 7 days by default from the current date. The count of the number of appointments to be listed in this view can be customized using the AgendaViewSettings.DaysInAgenda
.
@using MyProject.Models; // Here MyProject defines your project name to access the model class
@{
<!-- Datasource for Appointments -->
List<ScheduleFields> Appoint = new List<ScheduleFields>();
Appoint.Add(new ScheduleFields { Id = "1", Subject = "Meeting", StartTime = new DateTime(2015, 11, 10, 10, 00, 00), EndTime = new DateTime(2015, 11, 10, 11, 00, 00), Description = "", AllDay = false, Recurrence = false, RecurrenceRule = "" });
}
@(Html.EJ().Schedule("Schedule1")
.Width("100%")
.Height("525px")
.CurrentDate(new DateTime(2014, 6, 2))
.CurrentView(CurrentView.Agenda)
.AgendaViewSettings(agendaViewSettings => agendaViewSettings.DaysInAgenda(5))
.AppointmentSettings(fields => fields.Datasource(Appoint)
.Id("Id")
.Subject("Subject")
.StartTime("StartTime")
.EndTime("EndTime")
.AllDay("AllDay")
.Recurrence("Recurrence")
.RecurrenceRule("RecurrenceRule"))
)
NOTE
In Agenda view, the templates can be applied for the date and time columns. Also, the template passed through the
AppointmentTemplateId
will gets applied to the event column in Agenda view.
Restriction on View Navigation
It is possible to restrict the users to display only the specific list of views in the Schedule header section and also not to navigate to other views that are not listed.
For example, if the views property is set only with Month
view – then the Schedule header section displays only the Month option in the view toolbar and also other additional available actions like navigating to day/week view on clicking the month header dates and week date-range is stopped.
@using MyProject.Models; // Here MyProject defines your project name to access the model class
@{
<!-- Datasource for Appointments -->
List<ScheduleFields> Appoint = new List<ScheduleFields>();
Appoint.Add(new ScheduleFields { Id = "1", Subject = "Meeting", StartTime = new DateTime(2015, 11, 10, 10, 00, 00), EndTime = new DateTime(2015, 11, 10, 11, 00, 00), Description = "", AllDay = false, Recurrence = false, RecurrenceRule = "" });
}
@{List<string> views = new List<string>() { "Month" };}
@(Html.EJ().Schedule("Schedule1")
.Width("100%")
.Height("525px")
.Views(views)
.CurrentDate(new DateTime(2014, 6, 2))
.CurrentView(CurrentView.Agenda)
.AppointmentSettings(fields => fields.Datasource(Appoint)
.Id("Id")
.Subject("Subject")
.StartTime("StartTime")
.EndTime("EndTime")
.AllDay("AllDay")
.Recurrence("Recurrence")
.RecurrenceRule("RecurrenceRule"))
)
NOTE
Even though Week view is the active view in Scheduler by default, if it is not listed in the views collection – then the first listed option in the views collection will be taken as current view of the Scheduler.
Timeline View
Timeline view displays the day, time and its associated events horizontally arranged from left to right. By default, Scheduler renders in vertical mode and it can be changed to the timeline mode using Orientation
property which accepts both the string
and Orientation
enum value.
All the applicable features in Vertical mode works similar with Timeline mode (Horizontal) and only the visualization of the layout changes based on the orientation.
@using MyProject.Models; // Here MyProject defines your project name to access the model class
@{
<!-- Datasource for Appointments -->
List<ScheduleFields> Appoint = new List<ScheduleFields>();
Appoint.Add(new ScheduleFields { Id = "1", Subject = "Meeting", StartTime = new DateTime(2015, 11, 10, 10, 00, 00), EndTime = new DateTime(2015, 11, 10, 11, 00, 00), Description = "", AllDay = false, Recurrence = false, RecurrenceRule = "" });
}
@(Html.EJ().Schedule("Schedule1")
.Width("100%")
.Height("525px")
.CurrentDate(new DateTime(2014, 6, 2))
.Orientation(Orientation.Horizontal)
.AppointmentSettings(fields => fields.Datasource(Appoint)
.Id("Id")
.Subject("Subject")
.StartTime("StartTime")
.EndTime("EndTime")
.AllDay("AllDay")
.Recurrence("Recurrence")
.RecurrenceRule("RecurrenceRule"))
)