DatePicker / set a minimum date

340 views
Skip to first unread message

Dariusz

unread,
Jan 4, 2010, 8:52:59 AM1/4/10
to Google Web Toolkit
Hi!

Is there a function how to prevent people selecting a date, which is
in the past? Something like, setMinDate( Date date)?

Thanks

Ashar Lohmar

unread,
Jan 5, 2010, 9:02:49 AM1/5/10
to Google Web Toolkit
hi

1 ideea: make a class that extends DatePicker so that you'll call the
second constructor
protected DatePicker(MonthSelector monthSelector, CalendarView view,
CalendarModel model)

for the params use new DefaultMonthSelector(), new CalendarModel() and
instead of the , new DefaultCalendarView(),

use a class made by the source code of that with the following changes
in the inner class CellGrid (line 37)
you'll have to override the isEnabled() method so that it make the
check if the date is < lastDisabledDate

lastDisabled could be a property in the "MyDefaultCalendarView" and
also could/should be set by an method from the "MyDatePicker"

also you could add a ShowRangeHandlers<Date> that on onShowRange() ...
would iterate days between the start an end and do
datepicker.setTransientEnabledOnDates(false,date) on each iteration
or you could put the in a list and make the only once
datepicker.setTransientEnabledOnDates(false,dateList) (this will call
the first method so it'll be the same thing)

this second method it's a lot more time/resource consuming pick your
choice.


... hope this will help
Good luck

Fazeel Kazi

unread,
Jan 5, 2010, 12:51:53 AM1/5/10
to google-we...@googlegroups.com
Don't think there is anything for it.
You could implement ValueChangeHandler and throw an error when such a date is selected.

Regards.


--

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



Trevis

unread,
Jan 5, 2010, 11:50:27 AM1/5/10
to Google Web Toolkit
I'm using the datepicker for the first time and I'm looking for this
as well. It would also be nice to have a way to choose your year.
It's all but useless for entering birthdates.

Trevis

Reply all
Reply to author
Forward
0 new messages