简体   繁体   English

GWT SimplePager:如何在寻呼机上提供工具提示按钮,如first,last,next,previous?

[英]GWT SimplePager: How to provide tooltip on pagers button like first, last, next, previous?

I am using Custom Pager by extending Simple Pager. 我通过扩展Simple Pager来使用Custom Pager。 GWT version is 2.3 GWT版本是2.3

I want to provide tool-tip on SimplePagers button like first, last, next, previous. 我想在SimplePagers按钮上提供工具提示,如first,last,next,previous。

How can I achieve this ? 我怎样才能做到这一点?

Any help or guidance in this matter would be appreciated. 任何有关此事的帮助或指导将不胜感激。

This is actually not so easy to do, because SimplePager is not a very extendable class. 这实际上并不容易,因为SimplePager不是一个非常可扩展的类。 It doesn't provide access to its private button fields in any way, and it also doesn't assign unique style classes to each of them. 它不以任何方式提供对其私有按钮字段的访问,也不为每个按钮字段分配唯一的样式类。

One solution you could use is: 您可以使用的一个解决方案是:

final NodeList<Element> tdElems = 
    simplePager.getElement().getElementsByTagName("td");

for (int i = 0; i < tdElems.getLength(); i++) {

  final String toolTipText;

  if (i == 0)
    toolTipText = "First page";
  else if (i == 1)
    toolTipText = "Previous page";
  else if (i == 2)
    continue; /* This is the middle td - no button */
  else if (i == 3)
    toolTipText = "Next page";
  else if (i == 4)
    toolTipText = "Last page";
  else
    continue;

  tdElems.getItem(i).setTitle(toolTipText);
}

But honestly, this is not a very solid approach - it breaks if the layout of SimplePager changes in the future. 但老实说,这不是一个非常可靠的方法 - 如果SimplePager的布局在未来发生变化,它就会破裂。 I'd rather re-implement SimplePager, and access the button fields directly. 我宁愿重新实现SimplePager,并直接访问按钮字段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM