GWT日历或Datepicker显示一年中的季节

时间:2012-05-22 18:12:44

标签: gwt extjs calendar datepicker gxt

我正在尝试找到一年中显示日期范围的最佳组件。 一个想法是将月份显示为盒子(12盒)并用不同颜色绘制季节。

GWT Datepicker并不真正符合我的需求,因为它不够可扩展(http://code.google.com/p/google-web-toolkit/issues/detail?id=3848)。日历组件太复杂了。 GXT日期选择器也缺乏可扩展性。

这是我想要实现的一个例子:

Thats a simple sample of what I want to do

有什么想法吗?我正在使用GXT作为库。

1 个答案:

答案 0 :(得分:2)

在我看来,使用DatePicker并不是一个坏主意。这是一个涵盖一个月的小例子。我认为通过在网格中安排其中的12个将这一期延长到一整年并不会太难:

爪哇

final DateTimeFormat format = DateTimeFormat.getFormat("yyyy-MM-dd");

final DatePicker datePicker = new DatePicker();
datePicker.setCurrentMonth(format.parse("2012-01-01"));
datePicker.addStyleName("my-cal");

final Date start = format.parse("2012-01-17");
final Date end = format.parse("2012-01-28");

for (final Date date = start; date.compareTo(end) <= 0; CalendarUtil
    .addDaysToDate(date, 1)) {

  datePicker.addStyleToDates("my-green", date);
}

CSS

.my-green { background-color: green !important; }
.my-cal .datePickerPreviousButton { visibility: hidden; }
.my-cal .datePickerNextButton { visibility: hidden; }

使用“干净”主题,它看起来像这样:

enter image description here


P上。 S.以下是完整日历的外观:

enter image description here

完整代码:

http://pastebin.com/xkrRQQht