如何为vaadin表的项目或单元格添加工具提示

Kyl*_*tor 7 tooltip vaadin

我注意到vaadin 6.7.0 beta1支持为表格的行/单元格添加工具提示.但是,我没有找到任何添加它的示例.有没有人可以提供一些样品?

dan*_*yar 9

使用以下代码:

table.setItemDescriptionGenerator(new ItemDescriptionGenerator() {                             
public String generateDescription(Component source, Object itemId, Object propertyId) {
    if(propertyId == null){
        return "Row description "+ itemId;
    } else if(propertyId == COLUMN1_PROPERTY_ID) {
        return "Cell description " + itemId +","+propertyId;
    }                                                                       
    return null;
}}
Run Code Online (Sandbox Code Playgroud)


Mar*_*hin 1

您可以通过设置 formfieldfactory 来完成此操作。在这里,您可以返回一个看起来像带有 CSS 样式的文本的按钮。这将允许您在按钮上设置标题。这显然是一个丑陋的黑客行为。有关 vaadin 中的按钮和链接的更多信息

table.setTableFieldFactory(new TableFieldFactory() {

            // container is the datasource
            // item is the row
            // property  is the column
            //
            @Override
            public Field createField(Container container, Object itemId, Object propertyId, Component uiContext) {

        })
Run Code Online (Sandbox Code Playgroud)