How to add tooltip for a item or cell of a vaadin table

10,159

Solution 1

Use code as below:

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;
}}

Solution 2

You could accomplish this by setting a formfieldfactory. Here you could return a button that only loooks like text with styling CSS. This will let you set a caption on the button. This is obviously a ugly hack. More info about buttons and links in 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) {

        })
Share:
10,159
Kyleinincubator
Author by

Kyleinincubator

Updated on June 18, 2022

Comments

  • Kyleinincubator
    Kyleinincubator almost 2 years

    I noticed that vaadin 6.7.0 beta1 supports to add tooltip for row/cell of a table. However, I did not find any example how to add it. Is there anybody who can provide some sample?

  • Hajo Thelen
    Hajo Thelen over 11 years
    It seems that this is only working for non editable tables. If make my table editable the tooltip/description disapears.