Giving the delete button a hover tooltip in gwt

爱⌒轻易说出口 提交于 2019-12-12 01:51:52

问题


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)?

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?

回答1:


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


来源:https://stackoverflow.com/questions/22560138/giving-the-delete-button-a-hover-tooltip-in-gwt

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