Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Customizing CalendarEvent titles in Month View

    Hi - I was wondering if it is possible to either hide the startDate component of CalendarEvents or completely customize the title of these events. We use the Month view to display a read-only view of all day events and the time is irrelevant to us, and can be confusing for our users. Our calendars are data bound and include all relevant information (startDate, endDate, description, eventId, name ... etc). We are on SmartGWT 6.1.

    Edit: Just to be clear as an example from your showcase (https://www.smartclient.com/smartgwt...endar_category) instead of "8:00 Meeting" or "9:00 Realtor" we would just want to display "Meeting" or "Realtor" without the time component which I believe is auto drawn from the startDate?.
    Last edited by brandontrogers; 6 Aug 2019, 08:44.

    #2
    You could override Calendar.getDayBodyHTML(), to return entirely custom content for a MonthView cell, but that's probably overkill - doing that would remove the builtin "+ Nnn more..." link (and it's menu) that shows when a day has many events, and you'd need to implement something similar yourself.

    Instead, as of builds dated August 8 and later (tomorrow), we've made a change so that you can override existing API Calendar.getEventHeaderHTML(event, view) instead, and that will now affect the titles of events when rendered as cell-content in a MonthView, as well as when rendered as EventCanvases in other views.

    Comment


      #3
      Thanks, will try this out.

      Comment


        #4
        Hi, I've tried to implement these two overrides and the SC.logWarn()s never fire. This is in SmartGWT 6.1p (v11.1p_2019-08-17/Enterprise Deployment (built 2019-08-17)) nightly build from August 17. Please let me know if this is incorrect usage.
        Code:
        final Calendar calendar = new Calendar() {
        
                    @Override
                    public String getEventHeaderHTML(CalendarEvent event) {
                        SC.logWarn(event.getName());
                        return event.getName();
                    }
        
                    @Override
                    public String getEventHeaderHTML(CalendarEvent event, CalendarView view) {
                        SC.logWarn(event.getName());
                        return event.getName();
                    }
        
                };

        Comment


          #5
          Sorry for the confusion here - instead of overriding the getters, you need to use the "setEventHeaderHTMLCustomizer()" API

          Let us know if that doesn't work as expected

          Regards
          Isomorphic Software

          Comment


            #6
            Hey Isomorphic,
            I tried using setEventHeaderHTMLCustomizer() but it does not seems to be working.

            Please find the code below:
            Even the logger is not getting printed when the events are being rendered.

            calendar.setEventHeaderHTMLCustomizer(new EventHeaderHTMLCustomizer() {

            @Override
            public String getEventHeaderHTML(CalendarEvent calendarEvent, CalendarView calendarView) {
            Logger.getLogger("").info("HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH");
            StringBuilder returnStr = new StringBuilder();
            CustomGridRecord record = recordMap.get(calendarEvent.getDescription());
            String orderDetailURL = getOrderDetailURL(calendarEvent, record);
            String link = createOrderDetailPageLink(calendarEvent, record, orderDetailURL);
            returnStr.append(link).append("<br>");
            return returnStr.toString();

            }
            });
            calendar.setEventBodyHTMLCustomizer(new EventBodyHTMLCustomizer() {

            @Override
            public String getEventBodyHTML(CalendarEvent calendarEvent, CalendarView calendarView) {
            Logger.getLogger("").info("HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH");
            StringBuilder returnStr = new StringBuilder();
            CustomGridRecord record = recordMap.get(calendarEvent.getDescription());
            String orderDetailURL = getOrderDetailURL(calendarEvent, record);
            String link = createOrderDetailPageLink(calendarEvent, record, orderDetailURL);
            returnStr.append(link).append("<br>");
            return returnStr.toString();

            }
            });

            Comment


              #7
              Having tested this in-house, we see no issues with setEventHeader/BodyHTMLCustomizer() - this test below works as expected for us against latest framework-code, if you run it and click somewhere to create a new event:

              Code:
                      Calendar calendar = new Calendar();  
                      calendar.setEventHeaderHTMLCustomizer(new EventHeaderHTMLCustomizer() {
                          @Override
                          public String getEventHeaderHTML(CalendarEvent calendarEvent, CalendarView calendarView) {
                              // return the event-name only
                              return calendarEvent.getName();
                          }
                      });
                      calendar.setEventBodyHTMLCustomizer(new EventBodyHTMLCustomizer() {
                          @Override
                          public String getEventBodyHTML(CalendarEvent calendarEvent, CalendarView calendarView) {
                              return "Identical Body Text";
                          }
                      });
                      calendar.draw();
              The next step is to try with the latest build from smartclient.com/builds - if you still have problems with that build, we'll need to see a standalone, runnable test-case that shows the issue.
              Last edited by Isomorphic; 9 Jan 2020, 23:11.

              Comment

              Working...
              X