Scheduler makes use of popups and dialog to display the required notifications, as well as includes an editor window with event fields for making the appointment creation and editing process easier. You can also easily customize the editor window and the fields present in it, and can also apply validations on those fields.
The editor window usually opens on the Scheduler, when a cell or event is double clicked. When a cell is double clicked, the detailed editor window opens in “Add new” mode, whereas when an event is double clicked, the same is opened in an “Edit” mode.
In mobile devices, you can open the detailed editor window in edit mode by clicking the edit icon on the popup, that opens on single tapping an event. You can also open it in add mode by single tapping a cell, which will display a +
indication, clicking on it again will open the editor window.
You can also prevent the editor window from opening, by rendering Scheduler in a
Readonly
mode or by doing code customization within thePopupOpen
event.
You can change the header title and the text of buttons displayed at the footer of the editor window by changing the appropriate localized word collection used in the Scheduler.
@using Syncfusion.EJ2.Schedule
@(Html.EJS().Schedule("schedule")
.Width("100%")
.Height("550px")
.Views(ViewBag.view)
.EventSettings(new ScheduleEventSettings { DataSource = ViewBag.datasource })
.SelectedDate(new DateTime(2018, 2, 15))
.Render()
)
<script type="text/javascript">
var L10n = ej.base.L10n;
L10n.load({
'en-US': {
'schedule': {
'saveButton': 'Add',
'cancelButton': 'Close',
'deleteButton': 'Remove',
'newEvent': 'Add Event',
},
}
});
</script>
public ActionResult Index()
{
ViewBag.datasource = GetScheduleData();
List<ScheduleView> viewOption = new List<ScheduleView>()
{
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Day },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Week },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.WorkWeek }
};
ViewBag.view = viewOption;
return View();
}
public List<AppointmentData> GetScheduleData()
{
List<AppointmentData> appData = new List<AppointmentData>();
appData.Add(new AppointmentData
{
Id = 1,
Subject = "Meeting",
StartTime = new DateTime(2018, 2, 15, 10, 0, 0),
EndTime = new DateTime(2018, 2, 15, 12, 30, 0),
IsAllDay = false,
});
return appData;
}
public class AppointmentData
{
public int Id { get; set; }
public string Subject { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public bool IsAllDay { get; set; }
}
To change the default labels such as Subject, Location and other field names in the editor window, make use of the Title
property available within the field option of EventSettings
.
@using Syncfusion.EJ2.Schedule
@(Html.EJS().Schedule("schedule")
.Width("100%")
.Height("650px")
.SelectedDate(new DateTime(2018, 2, 15))
.EventSettings(e => e.Fields(f => f.Subject(sub => sub.Name("Subject").Title("Summary"))
.Location(loc => loc.Name("Location").Title("Location"))
.Description(des => des.Name("Description").Title("Comments"))
.StartTime(st => st.Name("StartTime").Title("From"))
.EndTime(et => et.Name("EndTime").Title("To"))
)
.DataSource(ViewBag.datasource)
)
.Render()
)
public ActionResult Index()
{
ViewBag.datasource = GetScheduleData();
List<ScheduleView> viewOption = new List<ScheduleView>()
{
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Day },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Week },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.WorkWeek }
};
ViewBag.view = viewOption;
return View();
}
public List<AppointmentData> GetScheduleData()
{
List<AppointmentData> appData = new List<AppointmentData>();
appData.Add(new AppointmentData
{
Id = 1,
Subject = "Meeting",
StartTime = new DateTime(2018, 2, 15, 10, 0, 0),
EndTime = new DateTime(2018, 2, 15, 12, 30, 0),
IsAllDay = false,
});
return appData;
}
public class AppointmentData
{
public int Id { get; set; }
public string Subject { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public bool IsAllDay { get; set; }
}
It is possible to validate the required fields of the editor window from client-side before submitting it, by adding appropriate validation rules to each field. The appointment fields have been extended to accept both string
and object
type values. To perform validations, it is necessary to specify object values for the event fields.
@using Syncfusion.EJ2.Schedule
@{
var validationRules = new Dictionary<string, object>() { { "required", true } };
var locationValidationRules = new Dictionary<string, object>() { { "required", true }, { "regex", new string[] { "^[a-zA-Z0-9- ]*$", "Special character(s) not allowed in this field" } } };
var descriptionValidationRules = new Dictionary<string, object>() { { "required", true }, { "minLength", 5 }, { "maxLength", 500 } };
}
@(Html.EJS().Schedule("schedule")
.Width("100%")
.Height("650px")
.EventSettings(e => e.Fields(f => f.Subject(sub => sub.Name("Subject").Validation(validationRules))
.Location(loc => loc.Name("Location").Validation(locationValidationRules))
.Description(des => des.Name("Description").Validation(descriptionValidationRules))
.StartTime(st => st.Name("StartTime").Validation(validationRules))
.EndTime(et => et.Name("EndTime").Validation(validationRules))
)
.DataSource(ViewBag.datasource)
)
.SelectedDate(new DateTime(2018, 2, 15))
.Render()
)
public ActionResult Index()
{
ViewBag.datasource = GetScheduleData();
List<ScheduleView> viewOption = new List<ScheduleView>()
{
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Day },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Week },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.WorkWeek }
};
ViewBag.view = viewOption;
return View();
}
public List<AppointmentData> GetScheduleData()
{
List<AppointmentData> appData = new List<AppointmentData>();
appData.Add(new AppointmentData
{
Id = 1,
Subject = "Meeting",
StartTime = new DateTime(2018, 2, 15, 10, 0, 0),
EndTime = new DateTime(2018, 2, 15, 12, 30, 0),
IsAllDay = false,
});
return appData;
}
public class AppointmentData
{
public int Id { get; set; }
public string Subject { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public bool IsAllDay { get; set; }
}
Applicable validation rules can be referred from form validation documentation.
The additional fields can be added to the default event editor by making use of the PopupOpen
event which gets triggered before the event editor opens on the Scheduler. The PopupOpen
is a client-side event that triggers before any of the generic popups opens on the Scheduler. The additional field (any of the form elements) should be added with a common class name e-field
, so as to handle and process those additional data along with the default event object. In the following example, an additional field Event Type
has been added to the default event editor and its value is processed accordingly.
@using Syncfusion.EJ2.Schedule
@(Html.EJS().Schedule("schedule")
.Width("100%")
.Height("550px")
.Views(ViewBag.view)
.PopupOpen("onPopupOpen")
.EventSettings(new ScheduleEventSettings { DataSource = ViewBag.datasource })
.SelectedDate(new DateTime(2018, 2, 15))
.Render()
)
<script type="text/javascript">
function onPopupOpen(args) {
if (args.type === 'Editor') {
// Create required custom elements in initial time
if (!args.element.querySelector('.custom-field-row')) {
var row = ej.base.createElement('div', { className: 'custom-field-row' });
var formElement = args.element.querySelector('.e-schedule-form');
formElement.firstChild.insertBefore(row, args.element.querySelector('.e-title-location-row'));
var container = ej.base.createElement('div', { className: 'custom-field-container' });
var inputEle = ej.base.createElement('input', {
className: 'e-field', attrs: { name: 'EventType' }
});
container.appendChild(inputEle);
row.appendChild(container);
var drowDownList = new ej.dropdowns.DropDownList({
dataSource: [
{ text: 'Public Event', value: 'public-event' },
{ text: 'Maintenance', value: 'maintenance' },
{ text: 'Commercial Event', value: 'commercial-event' },
{ text: 'Family Event', value: 'family-event' }
],
fields: { text: 'text', value: 'value' },
value: (args.data).EventType,
floatLabelType: 'Always', placeholder: 'Event Type'
});
drowDownList.appendTo(inputEle);
inputEle.setAttribute('name', 'EventType');
}
}
}
</script>
public ActionResult Index()
{
ViewBag.datasource = GetScheduleData();
List<ScheduleView> viewOption = new List<ScheduleView>()
{
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Day },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Week },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.WorkWeek }
};
ViewBag.view = viewOption;
return View();
}
public List<AppointmentData> GetScheduleData()
{
List<AppointmentData> appData = new List<AppointmentData>();
appData.Add(new AppointmentData
{
Id = 1,
Subject = "Meeting",
StartTime = new DateTime(2018, 2, 15, 10, 0, 0),
EndTime = new DateTime(2018, 2, 15, 12, 30, 0),
IsAllDay = false,
});
return appData;
}
public class AppointmentData
{
public int Id { get; set; }
public string Subject { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public bool IsAllDay { get; set; }
}
In default event editor window, start and end time duration are processed based on the interval
value set within the TimeScale
property. By default, interval
value is set to 30, and therefore the start/end time duration within the event editor will be in a 30 minutes time difference. You can change this duration value by changing the duration
option within the PopupOpen
event as shown in the following code example.
@using Syncfusion.EJ2.Schedule
@(Html.EJS().Schedule("schedule")
.Width("100%")
.Height("550px")
.Views(ViewBag.view)
.PopupOpen("onPopupOpen")
.EventSettings(new ScheduleEventSettings { DataSource = ViewBag.datasource })
.SelectedDate(new DateTime(2018, 2, 15))
.Render()
)
<script type="text/javascript">
function onPopupOpen(args) {
if (args.type === 'Editor') {
args.duration = 60;
}
}
</script>
public ActionResult Index()
{
ViewBag.datasource = GetScheduleData();
List<ScheduleView> viewOption = new List<ScheduleView>()
{
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Day },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Week },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.WorkWeek }
};
ViewBag.view = viewOption;
return View();
}
public List<AppointmentData> GetScheduleData()
{
List<AppointmentData> appData = new List<AppointmentData>();
appData.Add(new AppointmentData
{
Id = 1,
Subject = "Meeting",
StartTime = new DateTime(2018, 2, 15, 10, 0, 0),
EndTime = new DateTime(2018, 2, 15, 12, 30, 0),
IsAllDay = false,
});
return appData;
}
public class AppointmentData
{
public int Id { get; set; }
public string Subject { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public bool IsAllDay { get; set; }
}
It is possible to prevent the display of editor and quick popup windows by passing the value true
to cancel
option within the PopupOpen
event.
@using Syncfusion.EJ2.Schedule
@(Html.EJS().Schedule("schedule")
.Width("100%")
.Height("550px")
.Views(ViewBag.view)
.PopupOpen("onPopupOpen")
.EventSettings(new ScheduleEventSettings { DataSource = ViewBag.datasource })
.SelectedDate(new DateTime(2018, 2, 15))
.Render()
)
<script type="text/javascript">
function onPopupOpen(args) {
args.cancel = true;
}
</script>
public ActionResult Index()
{
ViewBag.datasource = GetScheduleData();
List<ScheduleView> viewOption = new List<ScheduleView>()
{
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Day },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Week },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.WorkWeek }
};
ViewBag.view = viewOption;
return View();
}
public List<AppointmentData> GetScheduleData()
{
List<AppointmentData> appData = new List<AppointmentData>();
appData.Add(new AppointmentData
{
Id = 1,
Subject = "Meeting",
StartTime = new DateTime(2018, 2, 15, 10, 0, 0),
EndTime = new DateTime(2018, 2, 15, 12, 30, 0),
IsAllDay = false,
});
return appData;
}
public class AppointmentData
{
public int Id { get; set; }
public string Subject { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public bool IsAllDay { get; set; }
}
In case, if you need to prevent only specific popups on Scheduler, then you can check the condition based on the popup type. The types of the popup 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. |
EditorContainer |
For more event indicator popup. |
The quick info popups are the ones that gets opened, when a cell or appointment is single clicked on the desktop mode. On single clicking a cell, you can simply provide a subject and save it. Also, while single clicking on an event, a popup will be displayed where you can get the overview of the event information. You can also edit or delete those events through the options available in it.
By default, these popups are displayed over cells and appointments of Scheduler and to disable this action, set false
to ShowQuickInfo
property.
@using Syncfusion.EJ2.Schedule
@(Html.EJS().Schedule("schedule")
.Width("100%")
.Height("550px")
.ShowQuickInfo(false)
.Views(ViewBag.view)
.EventSettings(new ScheduleEventSettings { DataSource = ViewBag.datasource })
.SelectedDate(new DateTime(2018, 2, 15))
.Render()
)
public ActionResult Index()
{
ViewBag.datasource = GetScheduleData();
List<ScheduleView> viewOption = new List<ScheduleView>()
{
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Day },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Week },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.WorkWeek }
};
ViewBag.view = viewOption;
return View();
}
public List<AppointmentData> GetScheduleData()
{
List<AppointmentData> appData = new List<AppointmentData>();
appData.Add(new AppointmentData
{
Id = 1,
Subject = "Meeting",
StartTime = new DateTime(2018, 2, 15, 10, 0, 0),
EndTime = new DateTime(2018, 2, 15, 12, 30, 0),
IsAllDay = false,
});
return appData;
}
public class AppointmentData
{
public int Id { get; set; }
public string Subject { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public bool IsAllDay { get; set; }
}
The quick popup that opens while single clicking on the cells are not applicable on mobile devices.
By default, Add Title
text is displayed on the subject field of quick popup. To change the default watermark text, change the value of the appropriate localized word collection used in the Scheduler.
var L10n = ej.base.L10n;
L10n.load({
'en-US': {
'schedule': {
'addTitle' : 'New Title'
}
}
});
The look and feel of the built-in quick popup window, which opens when single clicked on the cells or appointments can be customized by making use of the QuickInfoTemplates
property of the Scheduler. There are 3 sub-options available to customize them easily,
@using Syncfusion.EJ2.Schedule
@(Html.EJS().Schedule("schedule")
.Width("100%")
.Height("550px")
.QuickInfoTemplates(qt => qt.Header("#headerTemplate")
.Content("#contentTemplate")
.Footer("#footerTemplate")
)
.Views(ViewBag.view)
.EventSettings(new ScheduleEventSettings { DataSource = ViewBag.datasource })
.SelectedDate(new DateTime(2018, 2, 15))
.Render()
)
<style>
.e-textlabel {
font-weight: bold;
padding-right: 5px;
}
.custom-event-editor td {
padding: 5px;
}
.e-quick-popup-wrapper .e-cell-content {
padding: 0 10px 10px 10px;
}
.e-quick-popup-wrapper .e-cell-content div {
padding-bottom: 10px;
}
.e-quick-popup-wrapper .e-cell-content .e-field {
border-left-width: 0;
border-top-width: 0;
border-right-width: 0;
height: 25px;
width: 100%;
}
.e-quick-popup-wrapper .e-event-content {
display: flex;
}
.e-quick-popup-wrapper .e-event-content img {
width: 100px;
}
.e-quick-popup-wrapper .e-event-header {
position: absolute;
right: 0;
}
.e-quick-popup-wrapper .e-cell-footer .e-event-create,
.e-quick-popup-wrapper .e-event-footer .e-event-edit {
position: absolute;
right: 0;
}
.e-quick-popup-wrapper .e-event-footer .e-event-delete {
padding-left: 100px;
}
.e-quick-popup-wrapper .e-event-content .subject {
padding-top: 30px;
font-weight: 500;
font-size: 14px;
}
</style>
<script id="headerTemplate" type="text/x-template">
<div>
${if (elementType === 'cell')}
<div class="e-cell-header">
<div class="e-header-icon-wrapper">
<button class="e-close" title="Close"></button>
</div>
</div>
${else}
<div class="e-event-header">
<div class="e-header-icon-wrapper">
<button class="e-close" title="CLOSE"></button>
</div>
</div>
${/if}
</div>
</script>
<script id="contentTemplate" type="text/x-template">
<div>
${if (elementType === 'cell')}
<div class="e-cell-content">
<form class="e-schedule-form">
<div>
<input class="subject e-field" type="text" name="Subject" placeholder="Title">
</div>
<div>
<input class="location e-field" type="text" name="Location" placeholder="Location">
</div>
</form>
</div>
${else}
<div class="e-event-content">
<div class="e-subject-wrap">
${if (Subject)}
<div class="subject">${Subject}</div>${/if} ${if (Location)}
<div class="location">${Location}</div>${/if} ${if (Description)}
<div class="description">${Description}</div>${/if}
</div>
</div>
${/if}
</div>
</script>
<script id="footerTemplate" type="text/x-template">
<div>
${if (elementType === 'cell')}
<div class="e-cell-footer">
<button class="e-event-details" title="Extra Details">Extra Details</button>
<button class="e-event-create" title="Add">Add</button>
</div>
${else}
<div class="e-event-footer">
<button class="e-event-edit" title="Edit">Edit</button>
<button class="e-event-delete" title="Delete">Delete</button>
</div>
${/if}
</div>
</script>
public ActionResult Index()
{
ViewBag.datasource = GetScheduleData();
List<ScheduleView> viewOption = new List<ScheduleView>()
{
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Day },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Week },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.WorkWeek }
};
ViewBag.view = viewOption;
return View();
}
public List<AppointmentData> GetScheduleData()
{
List<AppointmentData> appData = new List<AppointmentData>();
appData.Add(new AppointmentData
{
Id = 1,
Subject = "Meeting",
StartTime = new DateTime(2018, 2, 15, 10, 0, 0),
EndTime = new DateTime(2018, 2, 15, 12, 30, 0),
IsAllDay = false,
});
return appData;
}
public class AppointmentData
{
public int Id { get; set; }
public string Subject { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public bool IsAllDay { get; set; }
}
The quick popup in adaptive mode can also be customized using
QuickInfoTemplates
usinge-device
class.
The event editor window can be customized by making use of the EditorTemplate
option. Here, 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 template should contain the e-field class, so as 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.
As we are using our Syncfusion sub-components within our editor using template in the following example, the custom defined form elements needs to be configured as required Syncfusion components such as DropDownList and DateTimePicker within the PopupOpen
event. This particular step can be skipped, if the user needs to simply use the usual form elements.
@using Syncfusion.EJ2.Schedule
@(Html.EJS().Schedule("schedule")
.Width("100%")
.Height("550px")
.Views(ViewBag.view)
.PopupOpen("onPopupOpen")
.EventSettings(new ScheduleEventSettings { DataSource = ViewBag.datasource })
.EditorTemplate("#EventEditorTemplate")
.ShowQuickInfo(false)
.SelectedDate(new DateTime(2018, 2, 15))
.Render()
)
<style>
.custom-event-editor .e-textlabel {
padding-right: 15px;
text-align: right;
}
.custom-event-editor td {
padding: 7px;
padding-right: 16px;
}
</style>
<script id="EventEditorTemplate" type="text/template">
<table class="custom-event-editor" width="100%" cellpadding="5">
<tbody>
<tr>
<td class="e-textlabel">Summary</td>
<td colspan="4">
<input id="Subject" class="e-field e-input" type="text" value="" name="Subject" style="width: 100%" />
</td>
</tr>
<tr>
<td class="e-textlabel">Status</td>
<td colspan="4">
<input type="text" id="EventType" name="EventType" class="e-field" style="width: 100%" />
</td>
</tr>
<tr>
<td class="e-textlabel">From</td>
<td colspan="4">
<input id="StartTime" class="e-field" type="text" name="StartTime" />
</td>
</tr>
<tr>
<td class="e-textlabel">To</td>
<td colspan="4">
<input id="EndTime" class="e-field" type="text" name="EndTime" />
</td>
</tr>
<tr>
<td class="e-textlabel">Reason</td>
<td colspan="4">
<textarea id="Description" class="e-field e-input" name="Description" rows="3" cols="50" style="width: 100%; height: 60px !important; resize: vertical"></textarea>
</td>
</tr>
</tbody>
</table>
</script>
<script type="text/javascript">
function onPopupOpen(args) {
if (args.type === 'Editor') {
var statusElement = args.element.querySelector('#EventType');
if (!statusElement.classList.contains('e-dropdownlist')) {
var dropDownListObject = new ej.dropdowns.DropDownList({
placeholder: 'Choose status', value: statusElement.value,
dataSource: ['New', 'Requested', 'Confirmed']
});
dropDownListObject.appendTo(statusElement);
statusElement.setAttribute('name', 'EventType');
}
var startElement = args.element.querySelector('#StartTime');
if (!startElement.classList.contains('e-datetimepicker')) {
new ej.calendars.DateTimePicker({ value: new Date(startElement.value) || new Date() }, startElement);
}
var endElement = args.element.querySelector('#EndTime');
if (!endElement.classList.contains('e-datetimepicker')) {
new ej.calendars.DateTimePicker({ value: new Date(endElement.value) || new Date() }, endElement);
}
}
}
</script>
public ActionResult Index()
{
ViewBag.datasource = GetScheduleData();
List<ScheduleView> viewOption = new List<ScheduleView>()
{
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Day },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Week },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.WorkWeek },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Month }
};
ViewBag.view = viewOption;
return View();
}
public List<AppointmentData> GetScheduleData()
{
List<AppointmentData> appData = new List<AppointmentData>();
appData.Add(new AppointmentData
{
Id = 1,
Subject = "Meeting",
StartTime = new DateTime(2018, 2, 15, 10, 0, 0),
EndTime = new DateTime(2018, 2, 15, 12, 30, 0),
IsAllDay = false,
});
return appData;
}
public class AppointmentData
{
public int Id { get; set; }
public string Subject { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public bool IsAllDay { get; set; }
}
The resource field can be added within editor template with MultiSelect control for allow multiple resources.
@using Syncfusion.EJ2.Schedule
@(Html.EJS().Schedule("schedule")
.Width("100%")
.Height("550px")
.Group(group => group.Resources(ViewBag.Resources))
.Resources(res =>
{
res.DataSource(ViewBag.Owners)
.Field("OwnerId")
.Title("Owners")
.Name("Owners")
.AllowMultiple(true)
.TextField("text")
.IdField("id")
.ColorField("color")
.Add();
})
.PopupOpen("onPopupOpen")
.EventSettings(new ScheduleEventSettings { DataSource = ViewBag.datasource })
.EditorTemplate("#EventEditorTemplate")
.SelectedDate(new DateTime(2018, 2, 15))
.Render()
)
<style>
.custom-event-editor .e-textlabel {
padding-right: 15px;
text-align: right;
}
.custom-event-editor td {
padding: 7px;
padding-right: 16px;
}
</style>
<script id="EventEditorTemplate" type="text/x-template">
<table class="custom-event-editor" width="100%" cellpadding="5">
<tbody>
<tr>
<td class="e-textlabel">Summary</td>
<td colspan="4">
<input id="Subject" class="e-field e-input" type="text" value="" name="Subject" style="width: 100%" />
</td>
</tr>
<tr>
<td class="e-textlabel">From</td>
<td colspan="4">
<input id="StartTime" class="e-field" type="text" name="StartTime" />
</td>
</tr>
<tr>
<td class="e-textlabel">To</td>
<td colspan="4">
<input id="EndTime" class="e-field" type="text" name="EndTime" />
</td>
</tr>
<tr>
<td class="e-textlabel">Owner</td>
<td colspan="4">
<input type="text" id="OwnerId" name="OwnerId" class="e-field" style="width: 100%" />
</td>
</tr>
<tr>
<td class="e-textlabel">Reason</td>
<td colspan="4">
<textarea id="Description" class="e-field e-input" name="Description" rows="3" cols="50" style="width: 100%; height: 60px !important; resize: vertical">
</textarea>
</td>
</tr>
</tbody>
</table>
</script>
<script type="text/javascript">
function onPopupOpen (args) {
if (args.type === 'Editor') {
var ownerData = @Html.Raw(Json.Encode(ViewBag.Owners));
var startElement = args.element.querySelector('#StartTime');
if (!startElement.classList.contains('e-datetimepicker')) {
new ej.calendars.DateTimePicker({ value: new Date(startElement.value) || new Date() }, startElement);
}
var endElement = args.element.querySelector('#EndTime');
if (!endElement.classList.contains('e-datetimepicker')) {
new ej.calendars.DateTimePicker({ value: new Date(endElement.value) || new Date() }, endElement);
}
var processElement = args.element.querySelector('#OwnerId');
if (!processElement.classList.contains('e-multiselect')) {
var multiSelectObject = new ej.dropdowns.MultiSelect({
placeholder: 'Select a owner',
dataSource: ownerData,
fields: { text: 'text', value: 'id' },
});
multiSelectObject.appendTo(processElement);
}
}
}
</script>
public ActionResult Index()
{
ViewBag.datasource = GetEventsData();
List<OwnerRes> owners = new List<OwnerRes>();
owners.Add(new OwnerRes { text = "Nancy", id = 1, color = "#1aaa55" });
owners.Add(new OwnerRes { text = "Smith", id = 2, color = "#7fa900" });
owners.Add(new OwnerRes { text = "Paul", id = 3, color = "#357cd2" });
ViewBag.Owners = owners;
string[] resources = new string[] { "Owners" };
ViewBag.Resources = resources;
return View();
}
public class OwnerRes
{
public string text { set; get; }
public int id { set; get; }
public string color { set; get; }
}
public List<EventsData> GetEventsData()
{
List<EventsData> eventsData = new List<EventsData>();
eventsData.Add(new EventsData
{
Id = 1,
Subject = "Surgery - Nancy",
StartTime = new DateTime(2018, 2, 11, 10, 0, 0),
EndTime = new DateTime(2018, 2, 11, 12, 0, 0),
EventType = "Confirmed",
OwnerId = 1
});
eventsData.Add(new EventsData
{
Id = 2,
Subject = "Therapy - Smith",
StartTime = new DateTime(2018, 2, 12, 10, 0, 0),
EndTime = new DateTime(2018, 2, 12, 12, 0, 0),
EventType = "New",
OwnerId = 2
});
eventsData.Add(new EventsData
{
Id = 3,
Subject = "Surgery - Paul",
StartTime = new DateTime(2018, 2, 13, 10, 0, 0),
EndTime = new DateTime(2018, 2, 13, 12, 0, 0),
EventType = "Requested",
OwnerId = 3
});
return eventsData;
}
public class EventsData
{
public int Id { get; set; }
public string Subject { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public string EventType { get; set; }
public int OwnerId { get; set; }
}
In the following code example, validation has been added to the status field.
@using Syncfusion.EJ2.Schedule
@(Html.EJS().Schedule("schedule")
.Width("100%")
.Height("550px")
.PopupOpen("onPopupOpen")
.EditorTemplate("#EventEditorTemplate")
.EventSettings(new ScheduleEventSettings { DataSource = ViewBag.datasource })
.SelectedDate(new DateTime(2018, 2, 15))
.Render()
)
<style>
.custom-event-editor .e-textlabel {
padding-right: 15px;
text-align: right;
}
.custom-event-editor td {
padding: 7px;
padding-right: 16px;
}
</style>
<script id="EventEditorTemplate" type="text/x-template">
<table class="custom-event-editor" width="100%" cellpadding="5">
<tbody>
<tr>
<td class="e-textlabel">Summary</td>
<td colspan="4">
<input id="Subject" class="e-field e-input" type="text" value="" name="Subject" style="width: 100%" />
</td>
</tr>
<tr>
<td class="e-textlabel">Status</td>
<td colspan="4">
<input type="text" id="EventType" name="EventType" class="e-field" style="width: 100%" />
</td>
</tr>
<tr>
<td class="e-textlabel">From</td>
<td colspan="4">
<input id="StartTime" class="e-field" type="text" name="StartTime" />
</td>
</tr>
<tr>
<td class="e-textlabel">To</td>
<td colspan="4">
<input id="EndTime" class="e-field" type="text" name="EndTime" />
</td>
</tr>
<tr>
<td class="e-textlabel">Reason</td>
<td colspan="4">
<textarea id="Description" class="e-field e-input" name="Description" rows="3" cols="50" style="width: 100%; height: 60px !important; resize: vertical"></textarea>
</td>
</tr>
</tbody>
</table>
</script>
<script type="text/javascript">
function onPopupOpen(args) {
if (args.type === 'Editor') {
if (!ej.base.isNullOrUndefined(document.getElementById("EventType_Error"))) {
document.getElementById("EventType_Error").style.display = "none";
document.getElementById("EventType_Error").style.left = "351px";
}
var formElement = args.element.querySelector('.e-schedule-form');
var statusElement = args.element.querySelector('#EventType');
if (!statusElement.classList.contains('e-dropdownlist')) {
var dropDownListObject = new ej.dropdowns.DropDownList({
placeholder: 'Select a status', value: statusElement.value,
dataSource: ['New', 'Requested', 'Confirmed'],
select: valueChange
});
dropDownListObject.appendTo(statusElement);
}
function valueChange() {
if (!ej.base.isNullOrUndefined(document.getElementById("EventType_Error"))) {
document.getElementById("EventType_Error").style.display = "none";
}
}
var validator = ((formElement).ej2_instances[0]);
validator.addRules('EventType', { required: true });
var startElement = args.element.querySelector('#StartTime');
if (!startElement.classList.contains('e-datetimepicker')) {
new ej.calendars.DateTimePicker({ value: new Date(startElement.value) || new Date() }, startElement);
}
var endElement = args.element.querySelector('#EndTime');
if (!endElement.classList.contains('e-datetimepicker')) {
new ej.calendars.DateTimePicker({ value: new Date(endElement.value) || new Date() }, endElement);
}
}
}
</script>
public ActionResult Index()
{
ViewBag.datasource = GetScheduleData();
return View();
}
public List<AppointmentData> GetScheduleData()
{
List<AppointmentData> appData = new List<AppointmentData>();
appData.Add(new AppointmentData
{
Id = 1,
Subject = "Meeting",
StartTime = new DateTime(2018, 2, 15, 10, 0, 0),
EndTime = new DateTime(2018, 2, 15, 12, 30, 0),
IsAllDay = false,
});
return appData;
}
public class AppointmentData
{
public int Id { get; set; }
public string Subject { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public bool IsAllDay { get; set; }
}
The e-field class is not added to each field defined within the template, so you should allow to set those field values externally by using the popupClose
event.
Note: You can allow to retrieve the data only on the save
and delete
option. Data cannot be retrieved on the close
and cancel
options in the editor window.
The following code example shows how to save the customized event editor using a template by the popupClose
event.
@using Syncfusion.EJ2.Schedule
@(Html.EJS().Schedule("schedule")
.Width("100%")
.Height("550px")
.Views(ViewBag.view)
.PopupOpen("onPopupOpen")
.PopupClose("onPopupClose")
.EventSettings(new ScheduleEventSettings { DataSource = ViewBag.datasource })
.EditorTemplate("#EventEditorTemplate")
.ShowQuickInfo(false)
.SelectedDate(new DateTime(2018, 2, 15))
.Render()
)
<style>
.custom-event-editor .e-textlabel {
padding-right: 15px;
text-align: right;
}
.custom-event-editor td {
padding: 7px;
padding-right: 16px;
}
</style>
<script id="EventEditorTemplate" type="text/template">
<table class="custom-event-editor" width="100%" cellpadding="5">
<tbody>
<tr>
<td class="e-textlabel">Summary</td>
<td colspan="4">
<input id="Subject" class="e-input" type="text" name="Subject" style="width: 100%" />
</td>
</tr>
<tr>
<td class="e-textlabel">Status</td>
<td colspan="4">
<input type="text" id="EventType" name="EventType" style="width: 100%" />
</td>
</tr>
<tr>
<td class="e-textlabel">From</td>
<td colspan="4">
<input id="StartTime" type="text" name="StartTime" />
</td>
</tr>
<tr>
<td class="e-textlabel">To</td>
<td colspan="4">
<input id="EndTime" type="text" name="EndTime" />
</td>
</tr>
<tr>
<td class="e-textlabel">Reason</td>
<td colspan="4">
<textarea id="Description" class="e-input" name="Description" rows="3" cols="50" style="width: 100%; height: 60px !important; resize: vertical"></textarea>
</td>
</tr>
</tbody>
</table>
</script>
<script type="text/javascript">
function onPopupOpen(args) {
if (args.type === 'Editor') {
var subjectElement = args.element.querySelector('#Subject');
if (subjectElement) {
subjectElement.value = (args.data).Subject || "";
}
var statusElement = args.element.querySelector('#EventType');
if (!statusElement.classList.contains('e-dropdownlist')) {
var dropDownListObject = new ej.dropdowns.DropDownList({
placeholder: 'Choose status', value: (args.data).EventType,
dataSource: ['New', 'Requested', 'Confirmed']
});
dropDownListObject.appendTo(statusElement);
}
var startElement = args.element.querySelector('#StartTime');
if (!startElement.classList.contains('e-datetimepicker')) {
startElement.value = (args.data).StartTime;
new ej.calendars.DateTimePicker({ value: new Date(startElement.value) || new Date() }, startElement);
}
var endElement = args.element.querySelector('#EndTime');
if (!endElement.classList.contains('e-datetimepicker')) {
endElement.value = (args.data).EndTime;
new ej.calendars.DateTimePicker({ value: new Date(endElement.value) || new Date() }, endElement);
}
var descriptionElement = args.element.querySelector('#Description');
if (descriptionElement) {
descriptionElement.value = (args.data).Description || "";
}
}
}
function onPopupClose(args) {
if (args.type === 'Editor' && !ej.base.isNullOrUndefined(args.data)) {
var subjectElement = args.element.querySelector('#Subject');
if (subjectElement) {
(args.data).Subject = subjectElement.value;
}
var statusElement = args.element.querySelector('#EventType');
if (statusElement) {
(args.data).EventType = statusElement.value;
}
var startElement = args.element.querySelector('#StartTime');
if (startElement) {
(args.data).StartTime = startElement.value;
}
var endElement = args.element.querySelector('#EndTime');
if (endElement) {
(args.data).EndTime = endElement.value;
}
var descriptionElement = args.element.querySelector('#Description');
if (descriptionElement) {
(args.data).Description = descriptionElement.value;
}
}
}
</script>
public ActionResult Index()
{
ViewBag.datasource = GetScheduleData();
List<ScheduleView> viewOption = new List<ScheduleView>()
{
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Day },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Week },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.WorkWeek },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Month }
};
ViewBag.view = viewOption;
return View();
}
public List<AppointmentData> GetScheduleData()
{
List<AppointmentData> appData = new List<AppointmentData>();
appData.Add(new AppointmentData
{
Id = 1,
Subject = "Surgery - Andrew",
EventType = "Confirmed",
StartTime = new DateTime(2018, 2, 12, 9, 30, 0),
EndTime = new DateTime(2018, 2, 12, 10, 30, 0),
OwnerId = 3
});
return appData;
}
public class AppointmentData
{
public int Id { get; set; }
public string Subject { get; set; }
public string EventType { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public bool IsAllDay { get; set; }
public int OwnerId { get; set; }
}
In case, if you need to prevent only specific popups on Scheduler, then you can check the condition based on the popup type. The types of the popup 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. |
When the number of appointments count that lies on a particular time range * default appointment height exceeds the default height of a cell in month view and all other timeline views, a + more
text indicator will be displayed at the bottom of those cells. This indicator denotes that the cell contains few more appointments in it and clicking on that will display a popup displaying all the appointments present on that day.
To disable this option of showing popup with all hidden appointments, while clicking on the text indicator, you can do code customization within the
PopupOpen
event.
The same indicator is displayed on all-day row in calendar views such as day, week and work week views alone, when the number of appointment count present in a cell exceeds three. Clicking on the text indicator here will not open a popup, but will allow 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 while clicking on the more text indicator.
@using Syncfusion.EJ2.Schedule
@(Html.EJS().Schedule("schedule")
.Width("100%")
.Height("550px")
.Views(ViewBag.view)
.CurrentView(View.Month)
.PopupOpen("onPopupOpen")
.EventSettings(new ScheduleEventSettings { DataSource = ViewBag.datasource })
.SelectedDate(new DateTime(2018, 2, 15))
.Render()
)
<script type="text/javascript">
function onPopupOpen(args) {
if (args.type === 'EventContainer') {
args.cancel = true;
}
}
</script>
public ActionResult Index()
{
ViewBag.datasource = GetScheduleData();
List<ScheduleView> viewOption = new List<ScheduleView>()
{
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Day },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Week },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.WorkWeek },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Month }
};
ViewBag.view = viewOption;
return View();
}
public List<AppointmentData> GetScheduleData()
{
List<AppointmentData> appData = new List<AppointmentData>();
appData.Add(new AppointmentData{ Id = 1, Subject = "Meeting-1", StartTime = new DateTime(2018, 2, 15, 10, 0, 0), EndTime = new DateTime(2018, 2, 15, 12, 30, 0), IsAllDay = true });
appData.Add(new AppointmentData{ Id = 2, Subject = "Meeting-2", StartTime = new DateTime(2018, 2, 15, 10, 0, 0), EndTime = new DateTime(2018, 2, 15, 12, 30, 0), IsAllDay = true });
appData.Add(new AppointmentData{ Id = 3, Subject = "Meeting-3", StartTime = new DateTime(2018, 2, 15, 10, 0, 0), EndTime = new DateTime(2018, 2, 15, 12, 30, 0), IsAllDay = true });
appData.Add(new AppointmentData{ Id = 4, Subject = "Meeting-4", StartTime = new DateTime(2018, 2, 15, 10, 0, 0), EndTime = new DateTime(2018, 2, 15, 12, 30, 0), IsAllDay = true });
return appData;
}
public class AppointmentData
{
public int Id { get; set; }
public string Subject { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public bool IsAllDay { get; set; }
}
The following code example shows you how to customize the default more indicator popup in which number of events rendered count on the day has been shown in the header.
@using Syncfusion.EJ2.Schedule
@(Html.EJS().Schedule("schedule")
.Width("100%")
.Height("550px")
.Views(ViewBag.view)
.CurrentView(View.Month)
.PopupOpen("onPopupOpen")
.EventSettings(new ScheduleEventSettings { DataSource = ViewBag.datasource })
.SelectedDate(new DateTime(2018, 2, 15))
.Render()
)
<script type="text/javascript">
function onPopupOpen(args) {
if (args.type === 'EventContainer') {
var instance = new ej.base.Internationalization();
var date = instance.formatDate(args.data.date, { skeleton: 'MMMEd' });
args.element.querySelector('.e-header-date').innerText = date;
args.element.querySelector('.e-header-day').innerText = 'Event count: ' + args.data.event.length;
}
}
</script>
public ActionResult Index()
{
ViewBag.datasource = GetScheduleData();
List<ScheduleView> viewOption = new List<ScheduleView>()
{
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Day },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Week },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.WorkWeek },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Month }
};
ViewBag.view = viewOption;
return View();
}
public List<AppointmentData> GetScheduleData()
{
List<AppointmentData> appData = new List<AppointmentData>();
appData.Add(new AppointmentData{ Id = 1, Subject = "Meeting-1", StartTime = new DateTime(2018, 2, 15, 10, 0, 0), EndTime = new DateTime(2018, 2, 15, 12, 30, 0), IsAllDay = true });
appData.Add(new AppointmentData{ Id = 2, Subject = "Meeting-2", StartTime = new DateTime(2018, 2, 15, 10, 0, 0), EndTime = new DateTime(2018, 2, 15, 12, 30, 0), IsAllDay = true });
appData.Add(new AppointmentData{ Id = 3, Subject = "Meeting-3", StartTime = new DateTime(2018, 2, 15, 10, 0, 0), EndTime = new DateTime(2018, 2, 15, 12, 30, 0), IsAllDay = true });
appData.Add(new AppointmentData{ Id = 4, Subject = "Meeting-4", StartTime = new DateTime(2018, 2, 15, 10, 0, 0), EndTime = new DateTime(2018, 2, 15, 12, 30, 0), IsAllDay = true });
return appData;
}
public class AppointmentData
{
public int Id { get; set; }
public string Subject { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public bool IsAllDay { get; set; }
}
It is possible to prevent the display of popup window by passing the value true
to cancel
option within the MoreEventsClick
event.
@using Syncfusion.EJ2.Schedule
@(Html.EJS().Schedule("schedule")
.Width("100%")
.Height("550px")
.Views(ViewBag.view)
.CurrentView(View.Month)
.MoreEventsClick("onMoreEventsClick")
.EventSettings(new ScheduleEventSettings { DataSource = ViewBag.datasource })
.SelectedDate(new DateTime(2018, 2, 15))
.Render()
)
<script type="text/javascript">
function onMoreEventsClick(args) {
args.cancel = true;
}
</script>
public ActionResult Index()
{
ViewBag.datasource = GetScheduleData();
List<ScheduleView> viewOption = new List<ScheduleView>()
{
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Day },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Week },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.WorkWeek },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Month }
};
ViewBag.view = viewOption;
return View();
}
public List<AppointmentData> GetScheduleData()
{
List<AppointmentData> appData = new List<AppointmentData>();
appData.Add(new AppointmentData { Id = 1, Subject = "Meeting-1", StartTime = new DateTime(2018, 2, 15, 10, 0, 0), EndTime = new DateTime(2018, 2, 15, 12, 30, 0), IsAllDay = true });
appData.Add(new AppointmentData { Id = 2, Subject = "Meeting-2", StartTime = new DateTime(2018, 2, 15, 10, 0, 0), EndTime = new DateTime(2018, 2, 15, 12, 30, 0), IsAllDay = true });
appData.Add(new AppointmentData { Id = 3, Subject = "Meeting-3", StartTime = new DateTime(2018, 2, 15, 10, 0, 0), EndTime = new DateTime(2018, 2, 15, 12, 30, 0), IsAllDay = true });
appData.Add(new AppointmentData { Id = 4, Subject = "Meeting-4", StartTime = new DateTime(2018, 2, 15, 10, 0, 0), EndTime = new DateTime(2018, 2, 15, 12, 30, 0), IsAllDay = true });
return appData;
}
public class AppointmentData
{
public int Id { get; set; }
public string Subject { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public bool IsAllDay { get; set; }
}
The following code example shows you how to customize the moreEventsClick
property to navigate to the Day view when clicking on the more text indicator.
@using Syncfusion.EJ2.Schedule
@(Html.EJS().Schedule("schedule")
.Width("100%")
.Height("550px")
.Views(ViewBag.view)
.CurrentView(View.Month)
.MoreEventsClick("onMoreEventsClick")
.EventSettings(new ScheduleEventSettings { DataSource = ViewBag.datasource })
.SelectedDate(new DateTime(2018, 2, 15))
.Render()
)
<script type="text/javascript">
function onMoreEventsClick(args) {
args.isPopupOpen = false;
}
</script>
public ActionResult Index()
{
ViewBag.datasource = GetScheduleData();
List<ScheduleView> viewOption = new List<ScheduleView>()
{
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Day },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Week },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.WorkWeek },
new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Month }
};
ViewBag.view = viewOption;
return View();
}
public List<AppointmentData> GetScheduleData()
{
List<AppointmentData> appData = new List<AppointmentData>();
appData.Add(new AppointmentData { Id = 1, Subject = "Meeting-1", StartTime = new DateTime(2018, 2, 15, 10, 0, 0), EndTime = new DateTime(2018, 2, 15, 12, 30, 0), IsAllDay = true });
appData.Add(new AppointmentData { Id = 2, Subject = "Meeting-2", StartTime = new DateTime(2018, 2, 15, 10, 0, 0), EndTime = new DateTime(2018, 2, 15, 12, 30, 0), IsAllDay = true });
appData.Add(new AppointmentData { Id = 3, Subject = "Meeting-3", StartTime = new DateTime(2018, 2, 15, 10, 0, 0), EndTime = new DateTime(2018, 2, 15, 12, 30, 0), IsAllDay = true });
appData.Add(new AppointmentData { Id = 4, Subject = "Meeting-4", StartTime = new DateTime(2018, 2, 15, 10, 0, 0), EndTime = new DateTime(2018, 2, 15, 12, 30, 0), IsAllDay = true });
return appData;
}
public class AppointmentData
{
public int Id { get; set; }
public string Subject { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public bool IsAllDay { get; set; }
}