Hello,
is there a possibility to use HTML in the caption and description of calendar items?
Greetings
Andreas
Hello,
is there a possibility to use HTML in the caption and description of calendar items?
Greetings
Andreas
Hello @Andreas.Brueck!
For html caption, you can use the following code:
@Inject
protected Calendar<Date> calendar;
@Subscribe
protected void onInit(InitEvent event) {
com.vaadin.v7.ui.Calendar vCalendar = calendar.unwrap(com.vaadin.v7.ui.Calendar.class);
vCalendar.setEventCaptionAsHtml(true);
}
The CUBA platform and Vaadin do not have special methods to display event descriptions as an HTML. You need to follow a few steps to solve the problem:
web-toolkit
ModuleSampleCalendarConnector
class in web.toolkit.ui.client. package and override getTooltipInfo
method of CubaCalendarConnector
class:package com.company.sample.web.toolkit.ui.client;
import com.google.gwt.dom.client.Element;
import com.haulmont.cuba.web.widgets.CubaCalendar;
import com.haulmont.cuba.web.widgets.client.calendar.CubaCalendarConnector;
import com.vaadin.client.TooltipInfo;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.ContentMode;
@Connect(value = CubaCalendar.class, loadStyle = Connect.LoadStyle.LAZY)
public class SampleCalendarConnector extends CubaCalendarConnector {
@Override
public TooltipInfo getTooltipInfo(Element element) {
TooltipInfo tooltipInfo = super.getTooltipInfo(element);
tooltipInfo.setContentMode(ContentMode.HTML);
return tooltipInfo;
}
}
CubaCalendarConnector
with SampleCalendarConnector
in AppWidgetSet.gwt.xml file:<?xml version="1.0" encoding="UTF-8"?>
<module>
<inherits name="com.haulmont.cuba.web.widgets.WidgetSet"/>
<replace-with class="com.company.sample.web.toolkit.ui.client.SampleCalendarConnector">
<when-type-is class="com.haulmont.cuba.web.widgets.client.calendar.CubaCalendarConnector"/>
</replace-with>
</module>
Regards,
Gleb