如何将工具提示添加到celltable中的单元格?
问题描述:
我正在使用gwt cellTable。在这个单元格表中,我有一列包含compositeCell。现在我想为该复合单元格中的所有单元格添加工具提示。任何解决此问题的方法?
I am using gwt cellTable. In this cell table i have one column containing compositeCell. Now i want to add a tooltip for all cells in that composite cell. Any work around for this?
答
下面是一个抽象的工具提示列类,您可以扩展来代替普通的Column类: / p>
Here's an abstract tooltip column class that you can extend in place of the normal Column class:
public abstract class MyToolTipColumn<T, C> extends Column<T, C> {
interface Templates extends SafeHtmlTemplates {
@Template("<div title=\"{0}\">")
SafeHtml startToolTip(String toolTipText);
@Template("</div>")
SafeHtml endToolTip();
}
private static final Templates TEMPLATES = GWT.create(Templates.class);
private final String toolTipText;
public MyToolTipColumn(final Cell<C> cell, final String toolTipText) {
super(cell);
this.toolTipText = toolTipText;
}
@Override
public void render(final Context context, final T object, final SafeHtmlBuilder sb) {
sb.append(TEMPLATES.startToolTip(toolTipText));
super.render(context, object, sb);
sb.append(TEMPLATES.endToolTip());
}
}