gwtfullcalendargwtbootstrap3

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


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

How do you


Solution

  • The easiest way is to hook up on display viewRender event. 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:

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