Search code examples
gwtsmartgwt

Giving the delete button a hover tooltip in gwt


In this picture, as you can see there are the red deletion buttons, how do I create a hover tooltip for these buttons? Is it the same as setShowHover(true)?

enter image description here

Code:

HoverCustomizer customGroupTooltips = new HoverCustomizer()
        {
            @Override
            public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
                if (colNum == 1)
                {
                    return "tooltip message";
                }
                else if (colNum == 2)
                {
                    return "delete";
                }
                return null;
            }  
        };

        ListGridField name = new ListGridField(FIELD_NAME);
        ListGridField exportField = new IconField(FIELD_EXPORT, ICON.jpg, EXPORT_CUSTOM);

        exportField.setShowHover(true);
        exportField.setHoverCustomizer(customGroupTooltips.hoverHTML()); //how do i make sure it is colNum 1 message here?

Solution

  • Yes you can do it by using setHoverCustomizer() method on ListGridField.

    Here is the code:

        ListGrid grid = new ListGrid();
    
        grid.setCanHover(true);
        grid.setShowHover(true);
    
        ...
    
        grid.setCanRemoveRecords(true);
        ListGridField ls = new ListGridField();
        grid.setRemoveFieldProperties(ls);
        ls.setHoverCustomizer(new HoverCustomizer() {
    
            @Override
            public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
                return "click here to delete this record";
            }
        });