Calendar
A calendar is a common table used to display dates and corresponding schedules. VTable-Calendar is a calendar component developed based on the VTable component. Users can quickly implement a calendar tool or customize related business functions based on the powerful capabilities of VTable. Compared with traditional calendars, VTable-Calendar has the following advantages:
-
Stepless scrolling function, supports scrolling across months and years
-
Users familiar with VTable api can quickly get started with custom functions
Basic configuration of calendar
When creating a calendar, you can pass in the configuration corresponding to the calendar day:
Among them, option supports the following attributes
Attribute | Type | Description |
---|---|---|
startDate | Date | Calendar start date |
endDate | Date | Calendar end date |
currentDate | Date | Calendar day displayed |
rangeDays | number | The range of days displayed in the calendar (if startDate&endDate is not configured, the dates of rangeDays before and after currentDate will be taken as startDate&endDate, the default is 90 days) |
dayTitles | string[] | Calendar title (can be replaced with different languages) |
customEventOptions | ICustomEventOptions | Custom schedule configuration |
customEvents | ICustomEvent[] | Array of custom schedules |
tableOptions | ListTableConstructorOptions | Calendar table configuration (the configuration here will be passed to the corresponding VTable instance for deep customization) |
The properties configured in tableOptions
can be referred to VTable configuration for further configuration of the table. For example, if you want Saturday to be displayed in blue and Sunday in red in the calendar title, you can use the following configuration:
Customized calendar
Calendar supports two ways to customize the calendar, one for a single day and one for a multi-day schedule. The configuration of custom schedule is as follows:
Custom schedules can be configured during initialization, or dynamically added, deleted, and updated through the API.
Initialization configuration:
Dynamic addition, deletion, update:
Customized schedule APIs
Methods | Parameters | Description |
---|---|---|
addCustomEvent | ICustomEvent | Add a custom schedule |
addCustomEvents | ICustomEvent[] | Add custom schedules in batches |
removeCustomEvent | string | Delete custom schedules |
removeCustomEvents | string[] | Delete custom schedules in batches |
updateCustomEvent | ICustomEvent | Update custom schedules |
updateCustomEvents | ICustomEvent[] | Update custom schedules in batches |
Calendar events
Calendar supports the following events:
Event name | Description |
---|---|
calendar_date_click | Triggered when clicking on a calendar date |
selected_date | Triggered when a date is selected |
selected_date_clear | Triggered when a date is unselected |
drag_select_date_end | Triggered when dragging to select a date ends |
calendar_custom_event_click | Triggered when clicking on a custom schedule |
If further event processing is required, all events of VTable can be monitored through calendarInstance.table.on()
.