Editor Template in JavaScript Scheduler
The Scheduler provides popups and dialogs to display notifications and includes an editor window with event fields for streamlined appointment creation and editing. The editor window and its fields can be customized, and validations can be applied.
Event editor
The editor window opens when a cell or event is double-clicked. Double-clicking a cell opens the detailed editor in “Add new” mode, while double-clicking an event opens it in “Edit” mode.
On mobile devices, tap the edit icon on the popup that appears when single-tapping an event to open the editor in Edit mode. To open the editor in Add mode, single-tap a cell and tap the + indicator.
The editor window will not open when the Scheduler is in
readonlymode, and you can also cancel it in thepopupOpenevent.
Change the editor window header title and footer button text
Change the editor window header title and footer button text by modifying the appropriate localized word collection used by the Scheduler.
Change the label text of default editor fields
To change default labels such as Subject and Location, use the title property inside the eventSettings field options.
Field validation
Required fields in the editor window can be validated on the client side by adding validation rules via the validation property in the eventSettings field options. Appointment fields accept both string and object values; use object values to define validation rules.
See the form validation documentation for applicable validation rules.
Add additional fields to the default editor
Additional fields can be added to the default event editor using the popupOpen event, which triggers before the editor opens. Add form elements with the e-field class so their values are included in the event object. The example below adds an Event Type field and processes its value.
Customize the default time duration in editor window
In the default editor, start and end times are based on the interval value in the timeScale property. By default this is 30 (minutes). Change the duration by modifying the duration option in the popupOpen event.
How to prevent the display of editor and quick popups
The display of editor and quick popup windows can be prevented by passing the value true to the cancel option within the popupOpen event.
To prevent only specific popups on Scheduler, check the condition based on the popup type. The types of popups that can be checked within the popupOpen event are as follows.
| Type | Description |
|---|---|
| Editor | For Detailed editor window. |
| QuickInfo | For Quick popup which opens on cell click. |
| EditEventInfo | For Quick popup which opens on event click. |
| ViewEventInfo | For Quick popup which opens on responsive mode. |
| EventContainer | For more event indicator popup. |
| RecurrenceAlert | For edit recurrence event alert popup. |
| DeleteAlert | For delete confirmation popup. |
| ValidationAlert | For validation alert popup. |
| RecurrenceValidationAlert | For recurrence validation alert popup. |
Customize timezone collection in the editor window
By default, the timezone collections in the editor window are loaded with built-in timezone data. The timezone collections can be customized using the timezoneDataSource property with the collection of TimezoneFields data.
Close the editor window manually
The editor window can be closed using the closeEditor method.
Customize event editor using template
The event editor window can be customized using the editorTemplate option. The custom window design is built with the required fields using the script template and its type should be of text/x-template.
Each field defined within the template should contain the e-field class, to allow the processing of those field values internally. The ID of this customized script template section is assigned to the editorTemplate option, so that these customized fields will be replaced onto the default editor window.
Note: the
e-fieldclass is applicable for DropDownList, DateTimePicker, MultiSelect, DatePicker, CheckBox, and TextBox components because their values are processed internally.
When using Syncfusion sub-components inside the editor template, initialize those components (for example, DropDownList or DateTimePicker) in the popupOpen event. This is not necessary for standard HTML form elements.
Customize header and footer using template
The editor window’s header and footer can be enhanced with custom designs using the editorHeaderTemplate and editorFooterTemplate options. To achieve this, create a script template that includes the necessary fields. Ensure that the template type is set to text/x-template.
In this example, the editor’s header is customized according to the appointment’s subject field using
editorHeaderTemplate. The editorFooterTemplate is used to handle the functionality of validating specific fields before proceeding with the save action or canceling if validation requirements are not met.
Add resource options within editor template
The resource field can be added within the editor template with a multiselect control to allow multiple resource selection.
Add recurrence options within editor template
The following code example shows how to add recurrence options within the editor template by importing RecurrenceEditor.
Apply validations on editor template fields
In the following code example, validation has been added to the EventType field by using the popupOpen event. This field is set as required, and the validation message is displayed using the FormValidator class.
How to save the customized event editor using template
If the e-field class is not added to each field in the template, set those field values externally using the popupClose event.
Note: Data can be retrieved only on the save and delete actions; data is not available on the close or cancel actions.
The following code example shows how to save the customized event editor using a template with the popupClose event.
To prevent only specific popup closures on Scheduler, check the condition based on the popup type. The types of popups that can be checked within the popupClose event are as follows.
| Type | Description |
|---|---|
| Editor | For Detailed editor window. |
| QuickInfo | For Quick popup which opens on cell click. |
| EditEventInfo | For Quick popup which opens on event click. |
| ViewEventInfo | For Quick popup which opens on responsive mode. |
| EventContainer | For more event indicator popup. |
| RecurrenceAlert | For edit recurrence event alert popup. |
| DeleteAlert | For delete confirmation popup. |
| ValidationAlert | For validation alert popup. |
| RecurrenceValidationAlert | For recurrence validation alert popup. |
Quick popups
Quick info popups appear when a cell or appointment is single-clicked on desktop. Single-clicking a cell allows adding a subject and saving quickly. Single-clicking an event shows an overview popup with options to edit or delete the event.
By default, these popups are displayed over Scheduler cells and appointments. To disable them, set the showQuickInfo property to false.
The quick popup that opens when single-clicking cells is not available on mobile devices.
Open quick popup on multiple cell selection
The quick popup can be displayed immediately after multiple cells are selected in Scheduler by setting the quickInfoOnSelectionEnd property to true. By default, its value is false.
How to change the watermark text of quick popup subject
By default, Add Title text is displayed on the subject field of the quick popup. To change the default watermark text, modify the value of the appropriate localized word collection used in the Scheduler.
L10n.load({
'en-US': {
'schedule': {
'addTitle' : 'New Title'
}
}
});Customize quick popups
The look and feel of the built-in quick popup window that opens when single-clicking cells or appointments can be customized using the quickInfoTemplates property of the Scheduler. There are three sub-options available to customize:
- header - Accepts the template design that customizes the header part of the quick popup.
- content - Accepts the template design that customizes the content part of the quick popup.
- footer - Accepts the template design that customizes the footer part of the quick popup.
The quick popup in adaptive mode can also be customized using
quickInfoTemplateswith thee-deviceclass.
Open the quick info popup manually
The quick info popup in Scheduler can be opened using the openQuickInfoPopup public method. To open the cell quick info popup, pass the cell data as an argument to the method. To open the event quick info popup, pass the event data object as an argument to the method.
Close the quick info popup manually
The quick info popup in Scheduler can be closed using the closeQuickInfoPopup public method. The following code example demonstrates how to close the quick info popup manually.
More events indicator and popup
When the number of appointments in a particular time range exceeds the default appointment height of a cell in month view and all timeline views, a + more text indicator is displayed at the bottom of those cells. This indicator denotes that the cell contains additional appointments, and clicking on it displays a popup with all the appointments present on that day.
To disable the popup displaying all hidden appointments, when clicking on the text indicator, use code customization within the
popupOpenevent.
The same indicator is displayed on the all-day row in calendar views such as day, week and work week views, when the number of appointments present in a cell exceeds three. Clicking on the text indicator here does not open a popup, but allows the expand/collapse option for viewing the remaining appointments present in the all-day row.
The following code example shows how to disable the display of such popups when clicking on the more text indicator.
Customize the popup that opens on more indicator
The following code example shows how to customize the default more indicator popup by displaying the number of events rendered that day in the header.
Prevent the display of popup when clicking on the more text indicator
The display of the popup window can be prevented by passing the value true to the cancel option within the MoreEventsClick event.
Navigate to Day view when clicking on more text indicator
The following code example shows how to customize the moreEventsClick event to navigate to the Day view when clicking on the more text indicator.
Refer to our JavaScript Scheduler feature tour page for comprehensive feature demonstrations. You can also explore the JavaScript Scheduler example to learn how to present and manipulate data.