Datepicker
This page describes the properties of the Datepicker widget which can be used to display or capture date/time information. It enables to filter the data based on a date range, format dates and performs date validations.
Content properties
These properties are customizable options present in the property pane of the widget, allowing users to modify the widget according to their preferences.
Data
Date format ISO 8601 date string
Displays a list of date formats for the Datepicker widget. With JS enabled, this property accepts ISO 8601 date string formats.
You can also use the built-in Moment.js library in Appsmith to parse the date in the format required.
Example: If you want to convert the selected date and time to the IST timezone (Asia/Kolkata), click the JS button and add the following code:
{{
moment(datePickerName.selectedDate).tz("Asia/Kolkata").format()
}}
Default date ISO 8601 date string
Sets a default date that would be captured as user input unless it is changed by the user. With JS enabled, this property accepts ISO 8601 date string values.
First day of the week number
Sets which day of the week appears first within the calendar of the Datepicker's menu.
Time precision string
Decides whether a time is included within the Datepicker, and whether that time is to the minute or second precision. With JS enabled, it accepts the follwoing values - None
, minute
, or second
.
Label
Text string
Sets the label text displayed in the Datepicker widget.
Validation
Required
Enables you to designate the Datepicker widget as a mandatory field.
Min date ISO 8601 date string
Sets a minimum date permitted to be selected in the widget. With JS enabled, this property accepts ISO 8601 date string values.
Max date ISO 8601 date string
Sets a maximum date permitted to be selected with the widget. With JS enabled, this property accepts ISO 8601 date string values.
General
Tooltip
Sets a tooltip that appears when the user hovers over the widget. It enables you to add hints or provide additional information for the widget. Additionally, you can control it through JavaScript by clicking on the JS next to the property.
Visible boolean
Controls the visibility of the widget. If you turn off this property, the widget is not visible in View mode. Additionally, you can use JavaScript by clicking on JS next to the Visible property to control the widget's visibility conditionally.
For example, if you want to make the widget visible only when the user checks an item in a Checkbox widget, you can use the following JavaScript expression in the visible property of the Datepicker widget:
{{Checkbox1.isChecked}}
Disabled boolean
Prevents users from selecting the widget. Even though the widget remains visible, user input is not permitted. Additionally, you can use JavaScript by clicking on JS next to the Disabled property to control the widget's disabled state conditionally.
For example, if you want to allow only a specific user to interact with the Datepicker widget, you can use the following JavaScript expression:
{{appsmith.user.email=="john@appsmith.com"?false:true}}
Animate Loading boolean
Controls whether the widget is displayed with a loading animation. When enabled, the widget shows a skeletal animation during the loading process. Additionally, you can control it through JavaScript by clicking on the JS next to the property.
Show shortcuts boolean
When enabled, it adds section within the Datepicker pop-up that contains options - Today, 1 week ago, 1 month ago,3 months ago, 1 year ago, for quick date selection.
Close on selection boolean
Sets whether the Datepicker menu should automatically close upon user selection of a date.
Height string
This property determines how the widget's height adjusts to changes in its content. There are three available options:
- Fixed: The height of the widget remains as set using drag and resize.
- Auto Height: The widget's height adjusts dynamically in response to changes in its content.
- Auto Height with limits: Same as Auto height, with a configurable option to set the minimum and maximum number of rows the widget can occupy.
Events
When an event is triggered, these event handlers can execute queries, JS code, or other supported actions.
onDateSelected
Triggered when the user selects a date in the Datepicker widget.
onFocus
Triggered when the widget gets focus, when user clicks on the widget.
onBlur
Triggered when the widget loses focus, when the user clicks outside of the widget or interacts with another entity on the page.
Style properties
Style properties allow you to change the look and feel of the widget.
Label styles
Font color string
Enables you to set text color for the label. Additionally, click the JS button to programmatically modify the text color using JavaScript functions.