RangeDateField
RangeDateField can be used to limit the date selection to a specific date range, exclude some specific dates you don't want to be selectable, or exclude weekends altogether.
RangeDateField extends standard Vaadin DateField and allows you to restrict date selection to a specific set of dates. You can also set custom CSS styles to specific dates this way customizing the Look&Feel of the calendar.
Date selection can be restricted in the following way:
- by providing valid from or valid to date (or both);
- by specifying that weekends should be excluded;
- by configuring a specific list of days that should be disabled;
Sample code
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); RangeDateField dateField = new RangeDateField(); rangeDateField.setResolution(DateField.RESOLUTION_DAY); // all dates before this will be disabled rangeDateField.setValidFromDate(dateFormat.parse("2013-05-02")); // all dates after this will be disabled rangeDateField.setValidToDate(dateFormat.parse("2013-05-02")); // all dates included in this array will be disabled rangeDateField.setExcludeDates(new Date[] {dateFormat.parse("2013-05-14"), dateFormat.parse("2013-05-22")}); // weekends will be disabled rangeDateField.setExcludeWeekends(true); // this will set a custom CSS style name to a specific day, use any CSS style name you want rangeDateField.addDateStyleName(dateFormat.parse("2013-05-24"), "birthday"); rangeDateField.addDateStyleName(dateFormat.parse("2013-05-26"), "busy-day"); rangeDateField.addDateStyleName(dateFormat.parse("2013-05-26"), "highlight"); // you can remove a style from a specific day as well rangeDateField.removeDateStyleName(dateFormat.parse("2013-05-24"), "birthday"); // or remove all styles from a day rangeDateField.removeDateStyleNames(dateFormat.parse("2013-05-26"));
Links
Compatibility
Was this helpful? Need more help?
Leave a comment or a question below. You can also join
the chat on Discord or
ask questions on StackOverflow.
Version
- Released
- 2013-05-25
- Maturity
- BETA
- License
- Apache License 2.0
Compatibility
- Framework
- Vaadin 6.6+
- Browser
- Browser Independent
RangeDateField - Vaadin Add-on Directory
RangeDateField can be used to limit the date selection to a specific date range, exclude some specific dates you don't want to be selectable, or exclude weekends altogether.RangeDateField extends standard Vaadin DateField and allows you to restrict date selection to a specific set of dates. You can also set custom CSS styles to specific dates this way customizing the Look&Feel of the calendar.
Date selection can be restricted in the following way:
1) by providing valid from or valid to date (or both);
2) by specifying that weekends should be excluded;
3) by configuring a specific list of days that should be disabled;