CalendarEvent caption as HTML

Hi,

is there a way to enable HTML for the caption of calendar events?

I’m using io.jmix.ui.component.Calendar and io.jmix.ui.component.calendar.SimpleCalendarEvent in my code.

I found this solution, unfortunately that doesn’t work with the JMIX calendar component anymore.

Thanks in advance!

Hello!

Could you clarify version of Jmix do you use? I’ve tried the solution for event captions in 1.1.2 version and it still works:

@Autowired
private Calendar calendar;

@Subscribe
public void onInit(InitEvent event) {
    calendar.withUnwrapped(JmixCalendar.class, vCalendar -> vCalendar.setEventCaptionAsHtml(true));
}

To enable HTML description in Calendar you need to add compileWidget gradle task and widget configuration in the build.gradle:

dependencies {
   ...
   // implementation 'io.jmix.ui:jmix-ui-widgets-compiled' // comment or remove
   ...

   implementation 'io.jmix.ui:jmix-ui-widgets'
   widgets 'io.jmix.ui:jmix-ui-widgets'
}

compileWidgets {
    dependsOn(processResources)
    generate "com.company.myapp.widgets.CustomWidgetSet"
    includePaths('**/io/jmix/**/widget/**', '**/com/company/myapp/widgets/**')
}

And add app property for widget set:

jmix.ui.widgetSet=com.company.myapp.widgets.CustomWidgetSet

Then create the same connector class like in CUBA but with Jmix naming and place it under the package: com.company.myapp.widgets.client.

@Connect(value = JmixCalendar.class, loadStyle = Connect.LoadStyle.LAZY)
public class MyAppCalendarConnector extends JmixCalendarConnector {

    @Override
    public TooltipInfo getTooltipInfo(Element element) {
        TooltipInfo tooltipInfo = super.getTooltipInfo(element);
        tooltipInfo.setContentMode(ContentMode.HTML);
        return tooltipInfo;
    }
}

The result:
image

The demo project: trcalendar.zip (83.3 KB)

2 Likes

Thanks for your reply!

I currently use Jmix version 1.0.3, but your solution worked perfectly in my project, thank you very much!