代码之家  ›  专栏  ›  技术社区  ›  rmuller

如何在Vaadin流中显示网格单元工具提示

  •  1
  • rmuller  · 技术社区  · 7 年前

    使用vaadin8可以为网格单元设置工具提示。此功能在Vaadin流中不可用(当前使用的是v11.0.0)。有别的选择吗?

    1 回复  |  直到 7 年前
        1
  •  4
  •   Tatu Lund    7 年前

    目前还没有内置功能。最简单的方法可能是设置元素的“title”属性。一个例子是使用templaterender,这里有一个例子

    https://vaadin.com/components/vaadin-grid/java-examples/using-templates

    从上面的例子复制代码的相关部分

    grid.addColumn(TemplateRenderer.<Person> of(
            "<div title='[[item.name]]'>[[item.name]]<br><small>[[item.yearsOld]]</small></div>")
            .withProperty("name", Person::getName).withProperty("yearsOld",
                    person -> person.getAge() > 1
                            ? person.getAge() + " years old"
                            : person.getAge() + " year old"))
            .setHeader("Person");