v7.3.0

DatePicker
Widget

A Panel which can display a month of date cells, which navigates between the cells, fires events upon user selection actions, optionally navigates to other months in response to UI gestures, and optionally displays information about each date cell. Appearance in the built-in themes:

A date is selected (meaning a single value is selected if multiSelect is not set, or added to the selection if if set) by clicking a cell or by pressing Enter when focused on a cell.

The Shift and Ctrl keys modify selection behaviour depending on the value of multiSelect.

This class is used as a picker by the DateField class.

Styling cell content via CSS

Several different CSS classes are applied to date cells depending on their state. These can be used to style contents of cells via CSS.

  • b-disabled-date - Applied to disabled days
  • b-weekend - Applied to weekend days
  • b-past-date - Applied to dates before today
  • b-today - Applied to today's date
  • b-non-working-day - Applied to dates which are nonWorkingDays

By default, disabled dates in a lighter color. You can override this in your own CSS, using the CSS variable API of this class.

Custom cell rendering

You can easily control the content of each date cell using the cellRenderer. The example below shows a view typically seen when booking hotel rooms or apartments.

Multi selection

You can select multiple date ranges or a single date range using the multiSelect config.

Configuring toolbar buttons

The datepicker includes a few useful navigation buttons by default. Through the DatePicker´s toolbar, you can manipulate these, via the toolbar´s items config.

There are four buttons by default, each of which can be reconfigured using an object, or disabled by configuring them as null.

new DatePicker({
   tbar : {
      // Remove all navigation buttons
      items : {
          prevYear  : null,
          prevMonth : null,
          nextYear  : null,
          nextMonth : null
      }
   },
   bbar : {
       items : {
           todayButton : {
               text     : 'Today',
               style    : 'margin-inline:auto',
               onClick  : 'up.onTodayClick'
           }
       }
   },
   onTodayClick() {
       this.date = new Date();
   }
})

Provided toolbar widgets include:

  • prevMonth Navigates to previous month
  • nextMonth Navigates to next month
  • prevYear Navigates to previous year
  • nextYear Navigates to next year
No results

Configs

Configs are options you supply in a configuration object when creating an instance of this class
  • activeCls : String
    private

    The class name to add to the currently focused calendar cell.

  • The initially selected date (or a YYYY-MM-DD date string).

  • The DateHelper format string to format the day names.

  • By default, the month and year are editable. Configure this as false to prevent that.

  • By default, disabled dates cannot be navigated to, and they are skipped over during keyboard navigation. Configure this as true to enable navigation to disabled dates.

  • Configure as true to add a highlighted border and background to the week row which encapsulates the selected date.

    Has a corresponding runtime highlightSelectedWeek property.

  • By default, the year is visible. Configure this as false to prevent that.

  • The maximum selectable date. Selection of and navigation to dates after this date will not be possible.

  • The minimum selectable date. Selection of and navigation to dates prior to this date will not be possible.

  • The class name to add to the calendar cell whose date which is outside the minDate/maxDate range.

  • selectedCls : String
    private

    The class name to add to selected calendar cells.

Properties

Properties are getters/setters or publicly accessible variables on this class
  • Configure as true to add a highlighted border and background to the week row which encapsulates the selected date.

    Has a corresponding highlightSelectedWeek config.

  • isDatePicker : Booleantrue
    READONLY
    ADVANCED
    Identifies an object as an instance of DatePicker class, or subclass thereof.

Functions

Functions are methods available for calling on the class

    Events

    Events are triggered for certain actions in this class and can be listened for to react to those actions in your code

    Event handlers

    Event handlers are callbacks called as a result of certain actions in this class

    CSS variables

    CSS variables that can be set to adjust appearance
    Name Description
    --b-date-picker-cell-margin-block Block margin for the date cells
    --b-date-picker-color Color
    --b-date-picker-date-color Date color
    --b-date-picker-date-font-size Font size for the date elements
    --b-date-picker-date-padding Padding for the date elements
    --b-date-picker-day-color Day letter color
    --b-date-picker-day-font-size Font size for the day letters
    --b-date-picker-header-padding Date picker's header padding, when configured to be shown
    --b-date-picker-min-width Min-width of the entire picker
    --b-date-picker-selected-week-background Background for week containing the selected date, if configured to highlight it
    --b-date-picker-title-font-weight Font weight for the title
    --b-date-picker-today-background Today's date's background
    --b-date-picker-today-border Today's date's border
    --b-date-picker-today-color Today's date's color
    --b-date-picker-today-font-weight Font weight for today's date
    --b-date-picker-toolbar-color Color used on text and buttons in the date picker's top toolbar
    --b-date-picker-toolbar-font-size Font-size for the top toolbar (that holds the navigation buttons + month/year)
    Hovered
    --b-date-picker-date-hover-background Background for hovered date
    --b-date-picker-selected-hover-background Selected date's background when hovered
    --b-date-picker-today-hover-background Today's date's background when hovered
    Selected
    --b-date-picker-selected-background Background for selected date
    --b-date-picker-selected-color Selected date's text color
    --b-date-picker-selected-font-weight Font weight for the selected date
    --b-date-picker-selected-range-background Background for dates in a selected range (excluding first/last)
    --b-date-picker-selected-range-color Color for dates in a selected range (excluding first/last)
    --b-date-picker-selected-week-border-radius Border-radius for the selected week
    type: datepicker

    Source path

    Core/widget/DatePicker.js

    Contents