Tuning DateField
A DateField alternative which can be customized with custom styles and tooltip
Tuning DateField is a highly customizable alternative to Vaadin native DateField.
You can customize styles and cell rendering.
There is also an inline mode that displays the calendar directly.
From 1.19.0-vaadin8 version, java.time is used instead of Joda Time LocalDate (http://www.joda.org/joda-time/). You can wrap new version into CustomField that uses Joda for backward compatibility
A 3 resolution calendar (day, month, year) is used for fast time travelling
Go to https://github.com/fdreyfs/vaadin-tuning-datefield for installation instructions.
Sample code
final TuningDateField tuningDateField = new TuningDateField("Tuning DateField with US holidays"); // Add a cellItemCustomizer for holidays tuningDateField.setCellItemCustomizer(new CellItemCustomizerAdapter() { private HolidayManager holidayManager = HolidayManager.getInstance(); @Override public boolean isEnabled(LocalDate date, TuningDateField calendar) { return !holidayManager.isHoliday(date); } @Override public String getTooltip(LocalDate date, TuningDateField calendar) { if (holidayManager.isHoliday(date)) { Holiday holiday = holidayManager.getHolidays(date.toInterval()).iterator().next(); return holiday.getDescription(); } else { return null; } } // CSS : // .tuning-datefield-calendar .holiday { // background-color: rgba(233, 237, 107, 0.5); // } @Override public String getStyle(LocalDate date, TuningDateField calendar) { if (holidayManager.isHoliday(date)) { return "holiday"; } else { return null; } } }); // A listener for date change which changes the date range tuningDateField.addDateChangeListener(new DateChangeListener() { @Override public void dateChange(DateChangeEvent event) { // Access the LocalDate model instead of the value (which is a String) LocalDate localDate = tuningDateField.getLocalDate(); // Modify the date range on the fly tuningDateField.setDateRange(localDate, null, "Allowed date start at " + localDate); } });
InlineTuningDateField inlineTuningDateField = new InlineTuningDateField(); inlineTuningDateField.setControlsEnabled(false);
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
#20 Fixed NPE when calling removeDateRange() method. Thanks to ohens for spotting the bug
- Released
- 2017-08-03
- Maturity
- BETA
- License
- Apache License 2.0
Compatibility
- Framework
- Vaadin 8.0+
- Vaadin 7.7+ in 0.18.0
- Vaadin 7.1+ in 0.17.0
- Browser
- Internet Explorer
- Firefox
- Opera
- Safari
- Google Chrome
- Internet Explorer
- Internet Explorer
- Internet Explorer
Tuning DateField - Vaadin Add-on Directory
A DateField alternative which can be customized with custom styles and tooltipOnline Demo
Issue Tracker
Source Code
Tuning DateField version 0.5.0
Fixed CSS bug on controls enable/disable
Tuning DateField version 0.6.0
Added InlineTuningDateField
Tuning DateField version 0.7.0
- You can now render calendar cells the way you want by injecting html div/span into each cells
- Use dateFormatter pattern string instead of Joda DateTimeFormatter (incompatible change)
- Fixed calendar popup position when field was near navigator borders.
- Fixed minor bugs
Tuning DateField version 0.8.0
Fixed issue #4 : now you can focus on the field programmatically
Tuning DateField version 0.10.0
null
Tuning DateField version 0.12.0
Fixed modal calendar popup issue on IE11
Fixed setDateTextReadOnly issue (#6). Thanks to ambrits spotting it.
Tuning DateField version 0.14.0
Allows to set a fix number of rows in days resolution calendar (this avoid the calendar to shrink/extend according the number of days in the month. Use setDisplayFixedNumberOfDayRows() method.
Fixed issue #9 where the first and last day of month are not reset when the locale is changed
Tuning DateField version 0.15.0
#10 Reset textfield value when formatter pattern is modified
Tuning DateField version 0.17.0
Fixed #15 : Removed silly guava third party dep to make it work with Vaadin 7.7.3
Allow to open calendar on textfield focus using setOpenCalendarOnFocusEnabled() method
Tuning DateField version 0.18.0
#16 Compiled with Vaadin 7.7 dependency. Use 0.17.0 version for Vaadin 7.1+
Tuning DateField version 0.19.0-vaadin8
Use of Vaadin 8.0+
Use of java.time instead of Joda
Tuning DateField version 0.20.0-vaadin8
#20 Fixed NPE when calling removeDateRange() method. Thanks to ohens for spotting the bug