自定义的gxt单元格可能会采取小工具 [英] Custom gxt Cell which may take Widget

查看:150
本文介绍了自定义的gxt单元格可能会采取小工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个可以放置Widget的列。
我有这个:

  import com.google.gwt.cell.client.AbstractCell; 
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.ui.Widget;

public class WidgetGridCell extends AbstractCell< Widget> {

Widget小部件;

public WidgetGridCell(Widget Widget){
this.widget = widget;
}

@Override
public void render(Context paramContext,
Widget param,SafeHtmlBuilder pb){

}
}

但我不知道如何在HTML中包含小部件



PS或者不是Widget,只有GWT Button才适合我。 解决方案

请参阅这里列举了许多AbstractCell实现的例子。



回答关于GWT按钮的问题:

  import com.google.gwt.cell.client.AbstractCell ; 
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.ui.Widget;

public class WidgetGridCell extends AbstractCell< Widget> {

Widget小部件;

public WidgetGridCell(Widget Widget){
this.widget = widget;

$ b @Override
public void render(Context paramContext,
Widget param,SafeHtmlBuilder pb){
Button aButton = new Button();
//将文本添加到按钮等等...
pb.append(SafeHtmlUtils.fromTrustedString(aButton.toString()));


尝试这种做法基本上不可行(也不可取)并渲染一个单元格内的整个小部件,但它听起来好像你真的试图从单元内渲染一个按钮。

AbstractCell是Cell接口的实现,它允许您定义要在单元格内呈现的HTML。如果您需要一个可响应事件的按钮,您需要定义自定义单元格以处理浏览器事件(如单击事件)。 Google在自定义单元格的文档方面做得很好,解释了如何做到这一点。



请参阅此链接: http://www.gwtproject.org/doc/latest/DevGuideUiCustomCells.html


I need a Column in which it was possible to put a Widget. I have this:

import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.ui.Widget;

public class WidgetGridCell extends AbstractCell<Widget> {

    Widget widget;

    public WidgetGridCell(Widget widget) {
        this.widget = widget;
    }

    @Override
    public void render(Context paramContext,
            Widget param, SafeHtmlBuilder pb) {

    }
}

But I do not know how to include the widget in HTML

P.S. Or not Widget, only GWT Button will suit me.

解决方案

See here for a number of examples of AbstractCell implementations.

To answer your question regarding a GWT button:

import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.ui.Widget;

public class WidgetGridCell extends AbstractCell<Widget> {

  Widget widget;

  public WidgetGridCell(Widget widget) {
      this.widget = widget;
  }

  @Override
  public void render(Context paramContext,
          Widget param, SafeHtmlBuilder pb) {
    Button aButton = new Button();
    // add text to the button, etc...
    pb.append(SafeHtmlUtils.fromTrustedString(aButton.toString()));
  }
}

It's largely not feasible (and not advisable) to try and render an entire widget within a cell element but it sounds as though you are really trying to render a button from within the cell.

AbstractCell is an implementation of the Cell interface which allows you to define the HTML to render within the cell. If you need a button which can respond to events you'll need to define your custom cell to handle browser events (such as the click event). Google does a good job in their documentation on custom cells explaining how you can go about doing that.

See this link: http://www.gwtproject.org/doc/latest/DevGuideUiCustomCells.html

这篇关于自定义的gxt单元格可能会采取小工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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