如何将ClickableTextCell渲染为GWT CellTable中的一个锚点? [英] How can I render a ClickableTextCell as an anchor in a GWT CellTable?

查看:124
本文介绍了如何将ClickableTextCell渲染为GWT CellTable中的一个锚点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在简单的TextCell()中有一个带有多列的CellTable。其中两列是通过ClickableTextCell()类可点击的,但我想改变它们的外观。什么是最简单的方法来获取单元格内容类似于锚标记,同时仍然在表中使用单元格?



我已经尝试了以下内容:
1.实现自定义渲染器以添加锚点标记
2.搜索Google寻找提示
3.忽略我的图书馆是否需要更改整个框架链接
4.滚动我的头穿过他们的键盘



有趣的是,这个简单的变化是多么令人讨厌。



我目前的思想是实现一个自定义的AnchorCell类型,它放置在一个锚点小部件中,而不是其他类型的,但我不确定需要做什么。



$ b

解决方案

pre> public class MyClickableCellText extends ClickableTextCell {

String style;
public MyClickableCellText()
{
super();
style =myClickableCellTestStyle;


$ b @Override
protected void render(Context context,SafeHtml value,SafeHtmlBuilder sb){
if(value!= null){
sb.appendHtmlConstant(< div class = \+ style +\>);
sb.append(value);
sb.appendHtmlConstant(< / div>);


$ b $ public void addStyleName(String style)
{
this.style = style;
}


}

(没有div,因为你对它的风格进行了硬编码):

  .myClickableCellTestStyle {
text-decoration:强调;




$ b你甚至可以通过不扩展ClickableTextCell来创建自己的单元格,但是扩展AbstractCell(更强大但需要更多解释)。问我是否需要它!


I've got a CellTable with multiple columns in simple TextCell()s. Two of the columns are 'clickable' via the ClickableTextCell() class, but I want to change how they look. What's the easiest way to get the cell contents to resemble an anchor tag, while still using a cell in the table?

I've tried the following: 1. Implement a custom renderer to add anchor tags 2. Scouring Google looking for hints 3. Ignoring 'my library does it you just have to change your entire framework' links 4. Rolling my head across they keyboard

It's funny how annoying this simple change is turning out to be.

My current thought is to implement a custom AnchorCell type which puts in an Anchor widget instead of whatever it does in the other ones, but I'm not sure what all would need to be done.

Any help is appreciated.

解决方案

As an example:

public class MyClickableCellText extends ClickableTextCell {

    String style;   
    public MyClickableCellText()
    {
        super();
        style = "myClickableCellTestStyle";
    }


     @Override
      protected void render(Context context, SafeHtml value, SafeHtmlBuilder sb) {
        if (value != null) {
          sb.appendHtmlConstant("<div class=\""+style+"\">");
          sb.append(value);
          sb.appendHtmlConstant("</div>");
        }
      }

     public void addStyleName(String style)
     {
         this.style = style; 
     }


}

And the style (without the div, because you are hardcoding the style on it):

.myClickableCellTestStyle{
    text-decoration:underline;

}

You can even create your own cell by not extending ClickableTextCell but extending AbstractCell (more powerful but need more explanation). Ask me if you need it!

这篇关于如何将ClickableTextCell渲染为GWT CellTable中的一个锚点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆