The calendar widget of smartgwt is quite powerful. But it lacks one important functionality, that is, scroll to the current time in case of month view.
But this feature can easily be enabled by working on the Workday feature which smartGWT calendar widget supports.
I wrote a simple function to achieve the same:
private void scrollToCurrentTime() {
int[] workDays = new int[1];
Date now = new Date();
workDays[0] = now.getDay();
int currentHour = now.getHours();
now.setHours(currentHour-1);
String start = DateTimeFormat.getFormat(
PredefinedFormat.TIME_SHORT).format(now);
now.setHours(currentHour+7);
String end = DateTimeFormat.getFormat(
PredefinedFormat.TIME_SHORT).format(now);
calendar.setWorkdays(workDays);
calendar.setWorkdayStart(start);
calendar.setWorkdayEnd(end);
calendar.setScrollToWorkday(true);
calendar.setShowWorkday(true);
}
But this feature can easily be enabled by working on the Workday feature which smartGWT calendar widget supports.
I wrote a simple function to achieve the same:
private void scrollToCurrentTime() {
int[] workDays = new int[1];
Date now = new Date();
workDays[0] = now.getDay();
int currentHour = now.getHours();
now.setHours(currentHour-1);
String start = DateTimeFormat.getFormat(
PredefinedFormat.TIME_SHORT).format(now);
now.setHours(currentHour+7);
String end = DateTimeFormat.getFormat(
PredefinedFormat.TIME_SHORT).format(now);
calendar.setWorkdays(workDays);
calendar.setWorkdayStart(start);
calendar.setWorkdayEnd(end);
calendar.setScrollToWorkday(true);
calendar.setShowWorkday(true);
}