Announcement

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

    Customizing label for events displayed in "monthMoreEventsLinkClick" menu.

    Hi Isomorphic,

    Is there a way to to customize what label is used for displaying an event in the "+ N more..." menu that appears?

    Thanks

    SmartClient Version: v10.1p_2016-04-20/Pro Deployment (built 2016-04-20)

    #2
    We've just exposed Calendar.monthMoreEventsLinkTitle, which lets you override the title of the actual "+ N more..." item itself.

    Is that what you meant? Or did you mean the titles of the items in that menu? If the latter, both the items in the cells and the items in the popup menu display the time and event.name.

    Comment


      #3
      I meant the titles of the items in that menu. We override the body HTML and need to customize the items in the menu to match.
      Thanks

      Comment


        #4
        Presently, the items in the cell and the items in the popup menu show the time and the name from the event - are you saying that you are configuring the text for these items when they're in the cell itself and that you want to do the same thing in the menu?

        If so, what are you doing now? Please show some code.
        Last edited by Isomorphic; 24 Apr 2016, 12:19.

        Comment


          #5
          Hi Isomorphic,

          I'll provide a snippet of code below with the basics of what we do in the getDayBodyHTML. Essentially, we have a workaround for an undesirable behaviour in IE8 through IE10. I believe we brought this issue up in the past, but at the time, there was no workaround in your API to deal with it.

          Code:
          @Override
              protected String getDayBodyHTML(Date date, CalendarEvent[] events, Calendar calendar, int rowNum, int colNum) {
                  String bodyHTML = super.getDayBodyHTML(date, events, calendar, rowNum, colNum);
                  ...
                  // If the bodyHTML is blank or there are no events, return the bodyHTML...
                  ...
                  // Deal with IE8-IE10 prompting to confirm navigating away from application when clicking an event.
                  bodyHTML = bodyHTML.replaceAll("href=", "onclick=");
                  bodyHTML = bodyHTML.replaceAll("<a", "<a href='#'");
          
                  for (CalendarEvent calendarEvent : events) {
                      // We initially use the event UUID as the name because we want to avoid issues with special characters in the name when using replaceAll.
                      String uuid = calendarEvent.getName();
                      String name = calendarEvent.getAttributeAsString(uuid);
                      ...
                      // Clean the event name, i.e. StringUtils.asHTML(name), etc.
                      ...
                      bodyHTML = bodyHTML.replaceAll(uuid, name);
                  }
          
                  return bodyHTML;
              }
          So essentially, the "+N more..." menu will display the UUID as the name. If we had a way to customize the menu item labels for events, that would be great.

          Thanks

          Comment


            #6
            To be clear, in order for this to work, the event label customizer would have to be specifically for the context-menu item labels.

            Comment


              #7
              This isn't currently supported - the titles of the items in the popup menu are set in internal code at the moment.

              However - it's possible that we could add a mechanism that would let you do this - for example, we may be able to expose the internal popup Menu instance as an autoChild so that you could add a cell formatter.

              Note, though, that this would be a new feature, and so may not be portable back to live versions, like 10.1.

              We'll update here once we've had a chance to look into it.

              Comment


                #8
                Thank you for the update.

                Comment


                  #9
                  We've gone ahead and exposed the internal Calendar.monthMoreEventsMenu autoChild, back to 5.1.

                  From tomorrow's builds, you can use Calendar.setAutoChildProperties("monthMoreEventsMenu", <Menu props>) to install a CellFormatter that returns a custom value for the "title" field, or just setItemTitle() for items you want to change.
                  Last edited by Isomorphic; 27 Apr 2016, 04:01.

                  Comment


                    #10
                    Thank you very much.

                    Comment


                      #11
                      Hi Isomorphic,

                      The menu autoChild worked great, thank you.

                      I have a couple follow up questions.

                      1. It would appear that when you have +N more..., the menu actually displays N+1 items, the top one being the last one displayed in the day body. Is this by design? In our case, it could lead to some confusion for the user.

                      2. If the +N more... is at the bottom of the Calendar, clicking it causes the scrollbar to appear and the menu is still slightly clipped.

                      Thanks

                      Comment


                        #12
                        We've been making some improvements in this area today - including fixes for both of the issues you mention.

                        These will hit tomorrow's builds.

                        Comment


                          #13
                          Quick follow-up - these changes hit 6.1 in time for the nightly builds, but not 6.0 - they're in place now, so will be in tomorrow's 6.0 builds.

                          Comment


                            #14
                            OK. Did they make the 5.1 builds?

                            Comment


                              #15
                              Yes - in 5.1, the monthMoreEventsMenu is exposed and the two issues you noted most recently are addressed.

                              You can test those in today's build.

                              Comment

                              Working...
                              X