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

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

问题描述

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

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?

我尝试了以下方法:1.实现自定义渲染器添加锚标签2. 搜索谷歌寻找提示3. 忽略我的库,你只需要更改整个框架"链接4. 在他们的键盘上滚动我的头

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.

我目前的想法是实现一个自定义 AnchorCell 类型,该类型放入一个 Anchor 小部件而不是它在其他小部件中所做的任何事情,但我不确定需要做什么.

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.

感谢任何帮助.

推荐答案

举个例子:

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


}

和样式(没有 div,因为您在其上硬编码样式):

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

.myClickableCellTestStyle{
    text-decoration:underline;

}

您甚至可以通过不扩展 ClickableTextCell 而是扩展 AbstractCell(更强大但需要更多解释)来创建自己的单元格.需要的话问我!

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天全站免登陆