简体   繁体   English

如何在GWT的Fullcalendar的下一个/上一个按钮上挂接事件?

[英]How to hook event on next/prev button of Fullcalendar with GWT?

Using https://gwtbootstrap3.github.io/gwtbootstrap3-demo/#fullcalendar 使用https://gwtbootstrap3.github.io/gwtbootstrap3-demo/#fullcalendar

How do you 你怎么

  • Hook and event on the next and previous button 下一个上一个按钮上的钩子和事件
  • Set background color to a specific date on the calendar 将背景颜色设置为日历上的特定日期

The easiest way is to hook up on display viewRender event. 最简单的方法是连接显示viewRender事件。 As documentation states: 文档所述:

This callback will get triggered when the user changes the view, or when any of the date navigation methods are called . 当用户更改视图或调用任何日期导航方法时,将触发此回调。

Here is the code: 这是代码:

GeneralDisplay generalDisplay = new GeneralDisplay();
generalDisplay.setViewRenderCallback(new ViewRenderCallback() {
    @Override
    public void windowResize(JavaScriptObject view) {
    }

    @Override
    public void viewRender(JavaScriptObject view, Element element) {
        Window.alert("viewRender");
    }

    @Override
    public void viewDestroy(JavaScriptObject view, Element element) {
    }

    @Override
    public void dayRender(JavaScriptObject moment, Element tdElement) {
    }
});

CalendarConfig config = new CalendarConfig();
config.setGeneralDisplay(generalDisplay);

final FullCalendar calendar = new FullCalendar(Document.get().createUniqueId(), ViewOption.month, config, false);

To set background for specific date just use Background events : 要设置特定日期的背景,只需使用Background events

Event backgroundEvent = new Event(Document.get().createUniqueId(), "");
backgroundEvent.setStart(new Date(1511136000000L));
backgroundEvent.setAllDay(true);
backgroundEvent.setRendering("background");
backgroundEvent.setBackgroundColor("red");
calendar.addEvent(backgroundEvent);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM