2017-10-09 88 views
0

我怎样才能把提示在特定网格单元GXT的鼠标?如何把一个工具提示在网格单元格中GXT的鼠标?

我可以把一个提示为整个网格,但没有找到一种方法,把特定网格单元。

更具体地说,我如何从网格单元中检索信息,以及当光标位于单元格上时,在工具提示中显示单元格中的某些信息。

回答

0

我认为最简单的方法是使用QuickTip类。这一个鼠标悬停侦听一些容器和示出了用于与qtip属性存在每个孩子DOM元素尖端。例如:

public class GxtToolTipInGxtGrid implements EntryPoint { 

    public static class Model { 
     private final String name; 

     public Model(String name) { 
      this.name = name; 
     } 

     public String getName() { 
      return name; 
     } 
    } 

    interface ModelProperties extends PropertyAccess<Model> { 
     ValueProvider<Model, String> name(); 
    } 

    private static List<Model> MODELS = Arrays.asList(new Model("John"), new Model("Mary")); 
    private static ModelProperties PROPERTIES = GWT.create(ModelProperties.class); 

    public void onModuleLoad() { 
     ListStore<Model> store = new ListStore<>(Model::getName); 
     store.addAll(MODELS); 

     List<ColumnConfig<Model, ?>> columns = new ArrayList<>(); 
     ColumnConfig<Model, Model> column = new ColumnConfig<>(new IdentityValueProvider<>(), 200, "Name with tooltip"); 
     column.setCell(new SimpleSafeHtmlCell<>(new AbstractSafeHtmlRenderer<Model>() { 
      @Override 
      public SafeHtml render(Model object) { 
       SafeHtmlBuilder sb = new SafeHtmlBuilder(); 
       //QuickTip will use this attribute (qtip) for showing the tip. 
       sb.appendHtmlConstant("<div qtip='" + object.getName() + "'>"); 
       sb.appendEscaped(object.getName()); 
       sb.appendHtmlConstant("</div>"); 
       return sb.toSafeHtml(); 
      } 
     })); 
     columns.add(column); 
     columns.add(new ColumnConfig<>(PROPERTIES.name(), 100, "Name w/o tooltip")); 

     Grid<Model> grid = new Grid<>(store, new ColumnModel<>(columns)); 
     RootPanel.get().add(grid); 
     //Attach QuickTip to grid 
     Scheduler.get().scheduleDeferred(() -> new QuickTip(grid)); 
    } 
} 

但是这是一个静态的方法。我的意思是,显示工具提示的决定以及在工具提示中显示的内容在渲染阶段已经做出了决定。但是,如果你需要一个动态的方法,那么QuickTip模拟的定制可能实行来完成。

而且,看Ext GWT (GXT) tooltip over a grid row。它可能包含其他解决方案。

0
  1. 在网格上注册Quicktip。

新QuickTip(myGrid)

  • 覆盖该小区的渲染功能有一个工具提示。

    public void render(Context context, ImageResource value, SafeHtmlBuilder sb){ 
            sb.appendHtmlConstant("<div qtip='TOOLTIPVALUE'>");   
            super.render(context, value, sb); 
            sb.appendHtmlConstant("</div>"); } 
    
  • 相关问题