Scheduler
Description
The Scheduler shows appointments in five views: Day (one or more days), Week, Month, Agenda and a Timeline with one lane per resource. A toolbar moves between ranges and views.
Appointments can be selected (Ctrl+click adds to the selection), dragged to another time, day or resource (Ctrl copies, Alt snaps to the minute), resized by their top or bottom edge, created by dragging across empty time or double-clicking a slot, and dropped in from elsewhere on the page with Scheduler.MakeDraggable.
The scheduler never changes the appointments it is given. Each gesture raises a request carrying the proposed change (OnMove, OnResize, OnCreate, OnDelete, …); the application updates its own list and passes it back with Appointments(...). A request nobody handles changes nothing on screen.
Usage
Create the scheduler with Scheduler(), give it resources and appointments, and apply the requests it raises to your own list. Give it a height: the body scrolls inside the box it is given.
Resource timeline
The Timeline view draws one lane per resource. ReadOnly() keeps selection, edit requests, tooltips and the context-menu event, and turns off every gesture that would change data. Views(...) limits what the view switcher offers.
Views and options
| Method | Effect |
| --- | --- |
| View(SchedulerView) | Day, Week (default), Month, Agenda or Timeline |
| Views(params SchedulerView[]) | the views the toolbar offers, in order |
| GoTo(DateTime), Previous(), Next(), GoToToday() | move the range |
| Now(DateTime) | override the clock used for the today highlight, the now line and the Today button |
| FirstDayOfWeek(DayOfWeek) | first day of the Week, Month and Timeline views (default Sunday) |
| VisibleDays(n), AgendaDays(n), TimelineDays(n) | range length of the Day (1), Agenda (7) and Timeline (7) views |
| VisibleHours(start, end), WorkHours(start, end), NoWorkHours() | hours drawn and the shaded working hours |
| SlotMinutes(n) | grid lines and drag snap step (default 30) |
| HourHeight(px), TimelineHourWidth(px), ColumnMinWidth(px) | scale of the time grid and the timeline |
| Grouping(SchedulerGrouping) | ByResource (default), ByDate or None: how Day and Week split columns by resource |
| ReadOnly(), SingleClickCreates(), TwelveHourClock(), HideToolbar() | behaviour |
| AppointmentTemplate(...), AppointmentTooltip(...), NoTooltips() | what an appointment shows |
| Labels(new SchedulerLabels { … }) | translations of the text the scheduler draws |
Requests and events
| Method | Raised when |
| --- | --- |
| OnMove(Action<SchedulerMoveRequest>) | an appointment is dragged to a new time or resource; IsCopy when Ctrl was held |
| OnResize(Action<SchedulerResizeRequest>) | an edge is dragged |
| OnCreate(Action<SchedulerSlot>) | empty time is dragged across, or a slot is double-clicked (a whole day in the all-day row and Month) |
| OnSlotClick(Action<SchedulerSlot>) | an empty slot is clicked |
| OnEdit(Action<SchedulerAppointment>) | an appointment is double-clicked, or Enter is pressed on it |
| OnContextMenu(Action<SchedulerAppointment, MouseEvent>) | an appointment is right-clicked |
| OnDelete(Action<IReadOnlyList<SchedulerAppointment>>) | Delete or Backspace is pressed with a selection |
| OnExternalDrop(Action<SchedulerDropRequest>) | something made with Scheduler.MakeDraggable is dropped on a slot |
| OnSelectionChanged(...), OnNavigate(...) | the selection, view or date changes |
Locked appointments (IsLocked) cannot be selected, moved, resized, deleted or edited; right-click still raises OnContextMenu. The scheduler does not expand recurrence rules: IsRecurring only draws a mark, so pass each occurrence as its own appointment.
API reference
public sealed class Scheduler : ComponentBase<Scheduler, HTMLElement>A calendar of appointments: Day, Week, Month, Agenda and a multi-resource Timeline view, with a toolbar to move between ranges and views. Appointments can be selected, dragged to another time or resource, resized by their edges, created by dragging across empty time or double-clicking a slot, and dropped in from outside. The scheduler never changes the appointments it is given. Every gesture is reported as a request carrying the proposed change (OnMove, OnResize, OnCreate, OnDelete, …); the application decides, updates its own data and hands the new list back through Appointments. An unhandled request changes nothing on screen. A burst of configuration calls on a scheduler already on the page costs one rebuild, on the next frame. The scroll position of each view survives a rebuild, so live updates do not jump the grid back to the morning.
- Namespace
- Tesserae
- Inheritance
- ComponentBase<Scheduler, HTMLElement> → Scheduler
Constructors
| Name | Description |
|---|---|
| Scheduler | Initializes a new instance of the Scheduler class. |
Properties
| Name | Description |
|---|---|
| CurrentAppointments | The appointments currently shown. |
| CurrentView | The view currently shown. |
| CurrentDate | The date the current range is built around. |
| SelectedAppointments | The selected appointments, in the order they were selected. |
public IReadOnlyList<SchedulerAppointment> CurrentAppointmentsThe appointments currently shown.
Methods
| Name | Description |
|---|---|
| Appointments | Replaces the appointments. Hand in the whole list after every change: the scheduler draws what it is given and keeps the selection by Id. |
| Resources | Sets the resources the Day and Week views split their columns by (see Grouping) and the Timeline draws one lane each for. Appointments that name none of them gather in an "Unassigned" column. |
| View | Switches to view. |
| Views | Sets which views the toolbar offers, in order. Defaults to all five. |
| GoTo | Moves the range to the one holding date. |
| Previous | Moves to the previous range, as the toolbar's left arrow does. |
| Next | Moves to the next range, as the toolbar's right arrow does. |
| GoToToday | Moves to the range holding today. |
| Now | Overrides what the scheduler treats as now: where the Today button goes, which day is highlighted and where the now line is drawn. Defaults to the clock, read on every rebuild. |
| FirstDayOfWeek | Sets the day a week starts on, for the Week, Month and Timeline views. Defaults to Sunday. |
| VisibleDays | Sets how many consecutive days the Day view shows. Defaults to 1. |
| AgendaDays | Sets how many days the Agenda lists, from the current date. Defaults to 7. |
| TimelineDays | Sets how many days the Timeline covers. Seven (the default) starts on the first day of the week; any other count starts on the current date. |
| VisibleHours | Limits the hours the time grid and the Timeline draw, from startHour up to endHour (0 to 24). Appointments outside are clipped to the edge. Defaults to the whole day. |
| WorkHours | Sets the working hours, shaded lighter in the time grid and the Timeline. Defaults to 08:00 to 17:00. |
| NoWorkHours | Turns the working-hours shading off. |
| SlotMinutes | Sets the length of a slot, in minutes: the time grid's minor lines and the step every drag snaps to (hold Alt while dragging to snap to the minute). Defaults to 30. |
| HourHeight | Sets the height of one hour in the Day and Week views, in pixels. Defaults to 48. |
| TimelineHourWidth | Sets the width of one hour in the Timeline, in pixels. Defaults to 24. |
| ColumnMinWidth | Sets the narrowest a Day or Week column gets, in pixels. Below it the grid scrolls sideways. Defaults to 90. |
| MonthMaxAppointments | Sets how many appointments a Month cell lists before it shows "+N more". Defaults to 3. |
| Grouping | Sets how the Day and Week views split their columns by resource. Defaults to ByResource. |
| TwelveHourClock | Writes times as 9:30 AM instead of 09:30. |
| ReadOnly | Stops every gesture that would change data: move, resize, create, external drop and Delete. Selection, edit requests, the context menu and tooltips keep working. |
| SingleClickCreates | Makes a single click on an empty slot request a new appointment, instead of a double-click. |
| HideToolbar | Hides the toolbar, for an application that drives View and GoTo itself. |
| Commands | Adds components to the right of the toolbar, before the view switcher. |
| Labels | Replaces the text the scheduler draws on its own, for translation. |
| AppointmentTemplate | Replaces what is drawn inside each appointment's block, chip, bar and agenda row. The block keeps its colour, selection outline and resize edges. |
| AppointmentTooltip | Replaces the tooltip shown over an appointment. Return null for none. |
| NoTooltips | Turns the appointment tooltips off. |
| OnMove | Raised when an appointment is dragged to a new time or resource. Nothing has changed yet. |
| OnResize | Raised when an appointment's start or end edge is dragged. Nothing has changed yet. |
| OnCreate | Raised when the user asks for a new appointment: by dragging across empty time, by double-clicking an empty slot (a one-hour slot in the time grid and Timeline, the whole day in the all-day row and Month cells), or with a single click when SingleClickCreates is on. |
| OnSlotClick | Raised on every click on an empty slot, before any create. |
| OnEdit | Raised when an appointment is double-clicked, or Enter is pressed on it. Locked appointments raise nothing. |
| OnContextMenu | Raised on a right-click on an appointment, with the pointer event to anchor a menu at (for example ContextMenu().ShowAt(...)). Setting a handler stops the browser's own menu there. |
| OnSelectionChanged | Raised whenever the selection changes. |
| OnDelete | Raised when Delete or Backspace is pressed with appointments selected (locked ones are left out). |
| OnExternalDrop | Raised when something made draggable with MakeDraggable is dropped on a slot. |
| OnNavigate | Raised when the toolbar changes the view or the date. |
| Select | Replaces the selection. |
| ClearSelection | Clears the selection. |
| DeleteSelected | Raises OnDelete for the selected appointments, as the Delete key does. |
| MakeDraggable<T> | Makes component a drag source the scheduler accepts: dropping it on a time slot, a Timeline lane or a Month cell raises OnExternalDrop with payload and a slot of duration. A ghost of that length follows the pointer over the scheduler. |
| Render | Renders the component's root HTML element. |
| Overload | |
|---|---|
| Appointments(IEnumerable<SchedulerAppointment>) | Replaces the appointments. Hand in the whole list after every change: the scheduler draws what it is given and keeps the selection by Id. |
| Appointments(SchedulerAppointment[]) | Replaces the appointments. |
Appointments(IEnumerable<SchedulerAppointment>)
public Scheduler Appointments(IEnumerable<SchedulerAppointment> appointments)Replaces the appointments. Hand in the whole list after every change: the scheduler draws what it is given and keeps the selection by Id.
Parameters
- appointments IEnumerable<SchedulerAppointment>
| Overload | |
|---|---|
| Resources(IEnumerable<SchedulerResource>) | Sets the resources the Day and Week views split their columns by (see Grouping) and the Timeline draws one lane each for. Appointments that name none of them gather in an "Unassigned" column. |
| Resources(SchedulerResource[]) | Sets the resources. |
Resources(IEnumerable<SchedulerResource>)
public Scheduler Resources(IEnumerable<SchedulerResource> resources)Sets the resources the Day and Week views split their columns by (see Grouping) and the Timeline draws one lane each for. Appointments that name none of them gather in an "Unassigned" column.
Parameters
- resources IEnumerable<SchedulerResource>
public Scheduler Views(params SchedulerView[] views)Sets which views the toolbar offers, in order. Defaults to all five.
public Scheduler Previous()Moves to the previous range, as the toolbar's left arrow does.
public Scheduler Next()Moves to the next range, as the toolbar's right arrow does.
public Scheduler Now(DateTime now)Overrides what the scheduler treats as now: where the Today button goes, which day is highlighted and where the now line is drawn. Defaults to the clock, read on every rebuild.
public Scheduler FirstDayOfWeek(DayOfWeek day)Sets the day a week starts on, for the Week, Month and Timeline views. Defaults to Sunday.
public Scheduler VisibleDays(int days)Sets how many consecutive days the Day view shows. Defaults to 1.
public Scheduler AgendaDays(int days)Sets how many days the Agenda lists, from the current date. Defaults to 7.
public Scheduler TimelineDays(int days)Sets how many days the Timeline covers. Seven (the default) starts on the first day of the week; any other count starts on the current date.
public Scheduler VisibleHours(int startHour, int endHour)Limits the hours the time grid and the Timeline draw, from startHour up to endHour (0 to 24). Appointments outside are clipped to the edge. Defaults to the whole day.
public Scheduler WorkHours(TimeSpan start, TimeSpan end)Sets the working hours, shaded lighter in the time grid and the Timeline. Defaults to 08:00 to 17:00.
public Scheduler SlotMinutes(int minutes)Sets the length of a slot, in minutes: the time grid's minor lines and the step every drag snaps to (hold Alt while dragging to snap to the minute). Defaults to 30.
public Scheduler HourHeight(double pixels)Sets the height of one hour in the Day and Week views, in pixels. Defaults to 48.
public Scheduler TimelineHourWidth(double pixels)Sets the width of one hour in the Timeline, in pixels. Defaults to 24.
public Scheduler ColumnMinWidth(double pixels)Sets the narrowest a Day or Week column gets, in pixels. Below it the grid scrolls sideways. Defaults to 90.
public Scheduler MonthMaxAppointments(int count)Sets how many appointments a Month cell lists before it shows "+N more". Defaults to 3.
public Scheduler Grouping(SchedulerGrouping grouping)Sets how the Day and Week views split their columns by resource. Defaults to ByResource.
public Scheduler TwelveHourClock(bool value = true)Writes times as 9:30 AM instead of 09:30.
public Scheduler ReadOnly(bool value = true)Stops every gesture that would change data: move, resize, create, external drop and Delete. Selection, edit requests, the context menu and tooltips keep working.
public Scheduler SingleClickCreates(bool value = true)Makes a single click on an empty slot request a new appointment, instead of a double-click.
public Scheduler HideToolbar(bool hide = true)Hides the toolbar, for an application that drives View and GoTo itself.
public Scheduler Commands(params IComponent[] commands)Adds components to the right of the toolbar, before the view switcher.
public Scheduler Labels(SchedulerLabels labels)Replaces the text the scheduler draws on its own, for translation.
public Scheduler AppointmentTemplate(Func<SchedulerAppointment, IComponent> template)Replaces what is drawn inside each appointment's block, chip, bar and agenda row. The block keeps its colour, selection outline and resize edges.
public Scheduler AppointmentTooltip(Func<SchedulerAppointment, IComponent> tooltip)Replaces the tooltip shown over an appointment. Return null for none.
public Scheduler OnMove(Action<SchedulerMoveRequest> onMove)Raised when an appointment is dragged to a new time or resource. Nothing has changed yet.
public Scheduler OnResize(Action<SchedulerResizeRequest> onResize)Raised when an appointment's start or end edge is dragged. Nothing has changed yet.
public Scheduler OnCreate(Action<SchedulerSlot> onCreate)Raised when the user asks for a new appointment: by dragging across empty time, by double-clicking an empty slot (a one-hour slot in the time grid and Timeline, the whole day in the all-day row and Month cells), or with a single click when SingleClickCreates is on.
public Scheduler OnSlotClick(Action<SchedulerSlot> onSlotClick)Raised on every click on an empty slot, before any create.
public Scheduler OnEdit(Action<SchedulerAppointment> onEdit)Raised when an appointment is double-clicked, or Enter is pressed on it. Locked appointments raise nothing.
public Scheduler OnContextMenu(Action<SchedulerAppointment, MouseEvent> onContextMenu)Raised on a right-click on an appointment, with the pointer event to anchor a menu at (for example ContextMenu().ShowAt(...)). Setting a handler stops the browser's own menu there.
public Scheduler OnSelectionChanged(Action<IReadOnlyList<SchedulerAppointment>> onSelectionChanged)Raised whenever the selection changes.
public Scheduler OnDelete(Action<IReadOnlyList<SchedulerAppointment>> onDelete)Raised when Delete or Backspace is pressed with appointments selected (locked ones are left out).
public Scheduler OnExternalDrop(Action<SchedulerDropRequest> onExternalDrop)Raised when something made draggable with MakeDraggable is dropped on a slot.
public Scheduler Select(params SchedulerAppointment[] appointments)Replaces the selection.
public Scheduler DeleteSelected()Raises OnDelete for the selected appointments, as the Delete key does.
public static T MakeDraggable<T>(T component, object payload, string title, TimeSpan duration) where T : IComponentMakes component a drag source the scheduler accepts: dropping it on a time slot, a Timeline lane or a Month cell raises OnExternalDrop with payload and a slot of duration. A ghost of that length follows the pointer over the scheduler.
internal static class SchedulerPointerExtensions- Namespace
- Tesserae
public enum SchedulerViewThe layouts a Scheduler can draw its appointments in.
- Namespace
- Tesserae
Values
| Name | Description |
|---|---|
| Day | A time grid of one or more consecutive days (see VisibleDays). |
| Week | A time grid of the seven days of the week the date falls in. |
| Month | The month the date falls in, as a grid of day cells with one chip per appointment. |
| Agenda | A list of the appointments of the coming days, grouped by date. |
| Timeline | One horizontal lane per resource over a week, time running left to right. |
MonthThe month the date falls in, as a grid of day cells with one chip per appointment.
public enum SchedulerGroupingHow a Scheduler's Day and Week views split their columns by resource.
- Namespace
- Tesserae
Values
| Name | Description |
|---|---|
| None | One column per day, every resource's appointments sharing it. |
| ByResource | One group per resource, each with a column per day. |
| ByDate | One group per day, each with a column per resource. |
public sealed class SchedulerAppointmentOne appointment shown by a Scheduler. A plain data object: map your own records onto it and keep the original in Tag. The scheduler never changes one; it reports what the user asked for and waits for the application to hand in the updated list.
- Namespace
- Tesserae
Properties
| Name | Description |
|---|---|
| Id | The appointment's identity, compared with Equals. Selection is kept by it across updates. |
| Title | The text on the appointment's block. |
| Description | A longer text, shown in the default tooltip and the agenda. |
| Start | Where the appointment begins, as wall-clock time. |
| End | Where the appointment ends, as wall-clock time. Must not be before Start. |
| IsAllDay | Draws the appointment in the all-day row instead of the time grid. An all-day appointment covers every day from Start's date up to, and not including, End — or Start's day alone when End is on the same date. |
| ResourceIds | The resources the appointment belongs to. One block is drawn per resource column or lane. |
| Color | A CSS colour for the block. Defaults to the first resource's colour, then the theme's primary colour. |
| IsLocked | Shows a lock mark and refuses every edit: no move, resize, delete or edit request. |
| IsRecurring | Shows a recurrence mark. The scheduler does not expand occurrences: hand each one in. |
| Tag | Any value the application wants to keep with the appointment. Never read by the scheduler. |
| Duration | The time between Start and End. |
public object Id { get; set; }The appointment's identity, compared with Equals. Selection is kept by it across updates.
public string Title { get; set; }The text on the appointment's block.
public string Description { get; set; }A longer text, shown in the default tooltip and the agenda.
public DateTime Start { get; set; }Where the appointment begins, as wall-clock time.
public DateTime End { get; set; }Where the appointment ends, as wall-clock time. Must not be before Start.
public bool IsAllDay { get; set; }Draws the appointment in the all-day row instead of the time grid. An all-day appointment covers every day from Start's date up to, and not including, End — or Start's day alone when End is on the same date.
public List<object> ResourceIds { get; set; }The resources the appointment belongs to. One block is drawn per resource column or lane.
public string Color { get; set; }A CSS colour for the block. Defaults to the first resource's colour, then the theme's primary colour.
public bool IsLocked { get; set; }Shows a lock mark and refuses every edit: no move, resize, delete or edit request.
public bool IsRecurring { get; set; }Shows a recurrence mark. The scheduler does not expand occurrences: hand each one in.
public object Tag { get; set; }Any value the application wants to keep with the appointment. Never read by the scheduler.
Methods
| Name | Description |
|---|---|
| Clone | Returns a copy of the appointment, with its own resource list. |
public sealed class SchedulerResourceA person, room or machine a Scheduler splits its columns and lanes by.
- Namespace
- Tesserae
Constructors
| Name | Description |
|---|---|
| SchedulerResource | Initializes a new instance of the SchedulerResource class. |
| Overload | |
|---|---|
| SchedulerResource() | Initializes a new instance of the SchedulerResource class. |
| SchedulerResource(object, string, string) | Initializes a new instance of the SchedulerResource class. |
public sealed class SchedulerMoveRequestAn appointment dragged to a new time and/or resource. Nothing has changed yet.
- Namespace
- Tesserae
Properties
| Name | Description |
|---|---|
| Appointment | The application's own appointment instance. |
| NewStart | The proposed start. |
| NewEnd | The proposed end; the duration is kept. |
| FromResourceId | The resource of the column or lane the drag started in, or null without resources. |
| ToResourceId | The resource of the column or lane it was dropped in, or null without resources. |
| IsCopy | Ctrl (or Cmd) was held on release: the user asked for a copy rather than a move. |
| ChangesResource | Whether the drop lands on another resource. |
public SchedulerAppointment Appointment { get; internal set; }The application's own appointment instance.
public DateTime NewStart { get; internal set; }The proposed start.
public DateTime NewEnd { get; internal set; }The proposed end; the duration is kept.
public object FromResourceId { get; internal set; }The resource of the column or lane the drag started in, or null without resources.
public object ToResourceId { get; internal set; }The resource of the column or lane it was dropped in, or null without resources.
public bool IsCopy { get; internal set; }Ctrl (or Cmd) was held on release: the user asked for a copy rather than a move.
public sealed class SchedulerResizeRequestAn appointment's start or end edge dragged. Nothing has changed yet.
- Namespace
- Tesserae
Properties
| Name | Description |
|---|---|
| Appointment | The application's own appointment instance. |
| NewStart | The proposed start. |
| NewEnd | The proposed end. |
public SchedulerAppointment Appointment { get; internal set; }The application's own appointment instance.
public DateTime NewStart { get; internal set; }The proposed start.
public sealed class SchedulerSlotA stretch of time on the scheduler: what the user dragged across or double-clicked to create an appointment, or the empty slot they clicked.
- Namespace
- Tesserae
Properties
| Name | Description |
|---|---|
| Start | Where the slot begins. |
| End | Where the slot ends. |
| ResourceId | The resource of the column or lane, or null. |
| IsAllDay | Whether the slot is a whole day (the all-day row or a month cell): End is the next midnight. |
| Event | The pointer event behind it, for anchoring a popup. |
public object ResourceId { get; internal set; }The resource of the column or lane, or null.
public bool IsAllDay { get; internal set; }Whether the slot is a whole day (the all-day row or a month cell): End is the next midnight.
public sealed class SchedulerDropRequestSomething dragged in from outside the scheduler and dropped on a slot (see MakeDraggable).
- Namespace
- Tesserae
Properties
| Name | Description |
|---|---|
| Payload | The payload handed to MakeDraggable. |
| Title | The title handed to MakeDraggable. |
| Start | Where it was dropped. |
| End | Start plus the duration handed to MakeDraggable. |
| ResourceId | The resource of the column or lane, or null. |
| IsAllDay | Whether it landed on a whole day (a month cell). |
public object Payload { get; internal set; }The payload handed to MakeDraggable.
public string Title { get; internal set; }The title handed to MakeDraggable.
public DateTime End { get; internal set; }Start plus the duration handed to MakeDraggable.
public object ResourceId { get; internal set; }The resource of the column or lane, or null.
public sealed class SchedulerLabelsThe text a Scheduler draws on its own, so an application can hand in its translations. Every property has an English default; set only the ones that need to change.
- Namespace
- Tesserae
Properties
| Name | Description |
|---|---|
| Today | The toolbar's button back to today. |
| Previous | The toolbar's previous-range button. |
| Next | The toolbar's next-range button. |
| Day | The Day view's name. |
| Week | The Week view's name. |
| Month | The Month view's name. |
| Agenda | The Agenda view's name. |
| Timeline | The Timeline view's name. |
| AllDay | The caption of the all-day row, and the agenda's time for an all-day appointment. |
| More | A month cell's overflow link; {0} is the number of appointments not shown. |
| NoAppointments | The agenda's text when there is nothing in its range. |
| Unassigned | The column or lane of appointments that name no resource. |
| Resources | The caption above the timeline's resource names. |
| MonthNames | The month names, January first. |
| ShortMonthNames | The short month names, January first. |
| DayNames | The weekday names, Sunday first. |
| ShortDayNames | The short weekday names, Sunday first. |
public string Previous { get; set; }The toolbar's previous-range button.
public string AllDay { get; set; }The caption of the all-day row, and the agenda's time for an all-day appointment.
public string More { get; set; }A month cell's overflow link; {0} is the number of appointments not shown.
public string NoAppointments { get; set; }The agenda's text when there is nothing in its range.
public string Unassigned { get; set; }The column or lane of appointments that name no resource.
public string Resources { get; set; }The caption above the timeline's resource names.
public string[] MonthNames { get; set; }The month names, January first.
public string[] ShortMonthNames { get; set; }The short month names, January first.
public string[] DayNames { get; set; }The weekday names, Sunday first.