EventEdit
Feature
Feature that displays a popup containing widgets for editing event data.
targetElement.innerHTML = '<p>Double click an event to show the event editor, or click + drag empty area to create a new one with the editor:</p>'; const scheduler = new Scheduler({ appendTo : targetElement, // makes scheduler as high as it needs to be to fit rows autoHeight : true, startDate : new Date(2018, 4, 6), endDate : new Date(2018, 4, 13), columns : [ { field : 'name', text : 'Name', width : 100 } ], resources : [ { id : 1, name : 'Bernard' }, { id : 2, name : 'Bianca' } ], events : [ { id : 1, resourceId : 1, name : 'Double click me', startDate : '2018-05-08', endDate : '2018-05-11' } ] }); To customize its contents you can:
- Reconfigure built-in widgets by providing override configs in the items config.
- Change the date format of the date & time fields: dateFormat and timeFormat
- Configure provided widgets in the editor and add your own in the items config.
- Remove fields related to recurring events configuration (such as
recurrenceCombo) by setting showRecurringUI config tofalse. - Advanced: Reconfigure the whole editor widget using editorConfig
Built-in widgets
The built-in widgets are:
| Widget ref | Type | Weight | Description |
|---|---|---|---|
nameField |
TextField | 100 | Edit name |
resourceField |
ResourceCombo | 200 | Pick resource(s) |
startDateField |
DateField | 300 | Edit startDate (date part) |
startTimeField |
TimeField | 400 | Edit startDate (time part) |
endDateField |
DateField | 500 | Edit endDate (date part) |
endTimeField |
TimeField | 600 | Edit endDate (time part) |
recurrenceCombo |
RecurrenceCombo | 700 | Select recurrence rule (only visible if recurrence UI is enabled) |
editRecurrenceButton |
RecurrenceLegendButton | 800 | Edit the recurrence rule (only visible if recurrence is used) |
colorField ¹ |
EventColorField | 700 | Choose background color for the event bar |
¹ Set the showEventColorPickers config to true to enable this field
Date and time fields
The date and time fields both keep the full date and time value of the event's start and end instant.
The date and time fields are partner linked pairs. Changing one will update the other to keep the full date/time value.
The start and end instants of the event are kept consistent while editing. Changing the start date/time will adjust the end date/time to keep the same duration.
The min of the end fields is kept in sync to be no earlier than the start instant.
The built-in buttons are:
| Widget ref | Type | Weight | Description |
|---|---|---|---|
saveButton |
Button | 100 | Save event button on the bbar |
deleteButton |
Button | 200 | Delete event button on the bbar |
cancelButton |
Button | 300 | Cancel event editing button on the bbar |
Removing a built-in item
To remove a built-in widget, specify its ref as null in the items config:
const scheduler = new Scheduler({
features : {
eventEdit : {
items : {
// Remove the start time field
startTimeField : null
}
}
}
})
Bottom buttons may be hidden using the bbar config passed to editorConfig:
const scheduler = new Scheduler({
features : {
eventEdit : {
editorConfig : {
bbar : {
items : {
deleteButton : null
}
}
}
}
}
})
To remove fields related to recurring events configuration (such as recurrenceCombo), set showRecurringUI config to false.
Customizing a built-in widget
To customize a built-in widget, use its ref as the key in the items config and specify the configs you want to change (they will merge with the widgets default configs):
const scheduler = new Scheduler({
features : {
eventEdit : {
items : {
// ref for an existing field
nameField : {
// Change its label
label : 'Description'
}
}
}
}
})
Adding custom widgets
To add a custom widget, add an entry to the items config. The name property links the input field to a field in the loaded event record:
const scheduler = new Scheduler({
features : {
eventEdit : {
items : {
// Key to use as fields ref (for easier retrieval later)
color : {
type : 'combo',
label : 'Color',
items : ['red', 'green', 'blue'],
// name will be used to link to a field in the event record when loading and saving in the editor
name : 'eventColor'
}
}
}
}
})
Video guides
For more info on customizing the event editor, please see "Customize event editor" guide.
This feature is enabled by default.
Useful configs and functions
| Member | Description |
|---|---|
| beforeEventEditShow | Fires before the editor is shown |
| beforeEventEdit | Fires before editing starts |
| beforeEventSave | Fires before save, return false to prevent |
| afterEventSave | Fires after event is saved |
| eventEditBeforeSetRecord | Fires before editor binds to a record |
See also
- SimpleEventEdit - Simplified event editor
- EventModel - Event data model
- EventEditor - Event editor popup
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
The current EventModel record, which is being edited by the event editor.
Has a corresponding runtime eventRecord property.
-
The week start day used in all date fields of the feature editor form by default. 0 means Sunday, 6 means Saturday. Defaults to the locale's week start day.
-
A CSS selector targeting elements that should not trigger the editor when clicked.
-
True to save and close this panel if ENTER is pressed in one of the input fields inside the panel.
-
The event that shall trigger showing the editor. Defaults to
eventdblclick, set to''or null to disable editing of existing events. -
This config parameter is passed to the
startDateFieldandendDateFieldconstructor. -
This config parameter is passed to the
startTimeFieldandendTimeFieldconstructor. -
Internal listeners, that cannot be removed by the user.
-
The widget which this plugin is to attach to.
Has a corresponding runtime client property.
-
Set to
falseto disable localization of this object. -
Set to
falseto hide recurring fields in event editor, even if the Recurring Events istrueand a recurring event is being edited.
Properties
Properties are getters/setters or publicly accessible variables on this class-
Identifies an object as an instance of EventEdit class, or subclass thereof.
-
Identifies an object as an instance of Events class, or subclass thereof.
-
Identifies an object as an instance of Localizable class, or subclass thereof.
-
Identifies an object as an instance of RecurringEventEdit class, or subclass thereof.
-
A class property getter for the default values of internal properties for this class.
-
Reference to the cancel button, if used
-
Reference to the delete button, if used
-
Returns the editor widget representing this feature
-
Reference to the end date field, if used
-
Reference to the end time field, if used
-
The current EventModel record, which is being edited by the event editor.
Has a corresponding eventRecord config.
-
Returns true if the editor is currently active
-
Reference to the name field, if used
-
Reference to the resource field, if used
-
Reference to the save button, if used
-
Reference to the start date field, if used
-
Reference to the start time field, if used
-
An empty array that can be used as a default value.
-
An empty object that can be used as a default value.
-
Identifies an object as an instance of EditBase class, or subclass thereof.
-
Identifies an object as an instance of EventEdit class, or subclass thereof.
-
Identifies an object as an instance of InstancePlugin class, or subclass thereof.
-
Returns a copy of the full configuration which was used to configure this object.
-
This property is set to
truebefore theconstructorreturns. -
This property is set to
trueon entry to the destroy method. It remains on the objects after returning fromdestroy(). If isDestroyed istrue, this property will also betrue, so there is no need to test for both (for example,comp.isDestroying || comp.isDestroyed). -
The Widget which was passed into the constructor, which is the Widget we are providing extra services for.
Has a corresponding client config.
-
Get the global LocaleHelper
-
Get the global LocaleManager
-
Reference to the button that opens the event repeat settings dialog, if used
-
Reference to the
Repeatevent field, if used
Functions
Functions are methods available for calling on the class-
This optional class method is called when a class is mixed in using the mixin() method.
-
Registers this class type with its Factory
-
Delete event being edited
Triggers: beforeEventDelete
-
loadRecord( )private
Sets fields values from record being edited
-
Saves the changes (applies them to record if valid, if invalid editor stays open)
Triggers: beforeEventSave, beforeEventAdd, afterEventSave
-
Updates record being edited with values from the editor
-
Internal function used to hook destroy() calls when using thisObj
-
Internal function used restore hooked destroy() calls when using thisObj
-
Auto detaches listeners registered from start, if set as detachable
-
Internal function used to run a callback function after an event is triggered
-
Removes all listeners registered to this object by the application.
-
This will merge a feature's (subclass of InstancePlugin) keyMap with it's client's keyMap.