Datepicker
The basic control for selecting a date.
Usage
{
type: "datepicker",
key?: string | string[],
wrap?: boolean, // false by default
css?: string,
disabled?: boolean, // false by default
hidden?: boolean, // false by default
height?: string | number | "content", // "content" by default
width?: string | number | "content", // "content" by default
padding?: string | number,
date?: Date | string,
dateFormat?: string, // "%d/%m/%y" by default
disabledDates?: (date: Date) => boolean,
icon?: string,
mark?: (date: Date) => string,
mode?: "calendar" | "month" | "year", // "calendar" by default
placeholder?: string,
thisMonthOnly?: boolean, // false by default
timeFormat?: 24 | 12, // 24 by default
timePicker?: boolean, // false by default
valueFormat?: "string" | "Date", // "string" by default
weekNumbers?: boolean, // false by default
weekStart?: "saturday" | "sunday" | "monday", // "sunday" by default
// for `wrap:true` check the label properties for the Fieldset
label?: string,
labelWidth?: string | number,
labelPosition?: "left" | "top", // "top" by default
// service properties and methods
$on?: { [eventName: string]: function },
$handler?: function,
$setValue?: function,
$layout?: function
}
Description
Basic properties
type
- (required) the type of a control. Set it to "datepicker"key
- (optional) the name of the specified/modified property or the path to it in the object of a Diagram itemwrap
- (optional) allows displaying the external wrapping. false by defaultcss
- (optional) adds style classes to a control stringdisabled
- (optional) defines whether a control is enabled (false) or disabled (true). false by defaulthidden
- (optional) defines whether a control is hidden. false by defaultheight
- (optional) the height of a control. "content" by defaultwidth
- (optional) the width of a control. "content" by defaultpadding
- (optional) sets padding between a cell and a border of a Datepicker controldate
- (optional) defines the date that will be opened when the calendar is createddateFormat
- (optional) defines the format of dates in the calendar. "%d/%m/%y" by default. The date format must include delimiters (space or symbol), otherwise an error will be throwndisabledDates
- (optional) allows disabling some date intervals, day labels are dimmedicon
- (optional) the CSS class of an icon from the used icon fontmark
- (optional) allows adding a CSS class to specific daysmode
- (optional) specifies the mode of displaying a calendar: "calendar" | "month" | "year". "calendar" by defaultplaceholder
- (optional) a tip for the inputthisMonthOnly
- (optional) hides dates of the previous/next months relative to the currently displayed onetimeFormat
- (optional) defines the time format of a timepicker, 12-hour or 24-hour: 12 | 24. 24 by defaulttimePicker
- (optional) adds a timepicker into a calendar. false by defaultvalueFormat
- (optional) defines the format of the value that will be returned while getting the current value of the control: "string" | "Date". "string" by defaultweekNumbers
- (optional) defines whether to show the numbers of weeks, false by defaultweekStart
- (optional) sets the starting day of the week: "saturday" | "monday" | "sunday". "sunday" by defaultlabel
- (optional) specifies a label for the controllabelWidth
- (optional) sets the label width of the controllabelPosition
- (optional) defines the position of a label: "left" | "top". "top" by default
Service properties and methods
warning
Note that it's highly not recommended to redefine the service properties and methods for the default types of controls, since it may cause breaks in their functionality.
$on
- (optional) - allows setting an event listener. The object has the following properties:eventName
- a callback function which is called with the following parameters:object
- an object with the following properties:control
- the Datepicker Form controleditor
- the object of the Diagram Editorid
- the id of a Diagram item
arguments
- (optional) - the original event arguments
$handler
- (optional) - a callback function that allows handling actions on firing thechange
andinput
events of a form control and thechange
event of DataCollection. Called with the following parameter:object
- an object with the following properties:id
- the id of a Diagram itemkey
- the name of the specified/modified property or the path to it in the object of a Diagram itemeditor
- the object of the Diagram Editorcontrol
- the object of the Datepicker Form control the component is built onvalue
- the new value of the Datepicker Form control
$setValue
- (optional) - a callback function that allows setting the value of the Datepicker Form control on initialization of a control and on changing the value in DataCollection. Called with the following parameter:object
- an object with the following properties:editor
- the object of the Diagram Editorcontrol
- the object of the Datepicker Form control the component is built onvalue
- the value of a Diagram item
$layout
- (optional) - a callback function that allows setting the structure of a control. Returns the configuration of the Datepicker Form control. Called with the following parameter:object
- the configuration of a control without service properties
Example
const editor = new dhx.DiagramEditor("editor_container", {
type: "org",
view: {
editbar: {
properties: {
$shape: [
{
type: "datepicker",
key: "date_start",
label: "Date start",
wrap: true,
},
{
type: "datepicker",
key: "date_end",
label: "Date end",
wrap: true,
valueFormat: "Date",
timePicker: true,
weekStart: "monday"
}
]
}
}
}
});
editor.parse([
{ "id": "shape_1" },
{ "id": "shape_2", "parent": "shape_1", "date_start": "25/03/24", "date_end": new Date },
{ "id": "shape_3", "parent": "shape_1", "date_start": "25/03/24", "date_end": new Date }
]);