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

丶灬走出姿态 提交于 2019-12-08 18:43:34

问题


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?


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



回答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) {

        })



回答3:


You can't add tooltpis (setDescription) to a row/cell nativly - not yet! It is already in there issue tracker but don't know when they will implement this feature



来源:https://stackoverflow.com/questions/7558119/how-to-add-tooltip-for-a-item-or-cell-of-a-vaadin-table

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!