Custom gxt Cell which may take Widget(自定义 gxt Cell 可能需要 Widget)
问题描述
我需要一个可以在其中放置小部件的列.我有这个:
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) {
}
}
但我不知道如何在 HTML 中包含小部件
But I do not know how to include the widget in HTML
附:或者不是 Widget,只有 GWT Button 适合我.
P.S. Or not Widget, only GWT Button will suit me.
推荐答案
参见这里 了解 AbstractCell 实现的一些示例.
See here for a number of examples of AbstractCell implementations.
要回答有关 GWT 按钮的问题:
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 是 Cell 接口的一个实现,它允许您定义要在单元格中呈现的 HTML.如果您需要一个可以响应事件的按钮,则需要定义自定义单元格来处理浏览器事件(例如单击事件).Google 在其关于自定义单元格的文档中做得很好,解释了如何去做.
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.
查看此链接:http://www.gwtproject.org/doc/latest/DevGuideUiCustomCells.html
这篇关于自定义 gxt Cell 可能需要 Widget的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:自定义 gxt Cell 可能需要 Widget
基础教程推荐
- RabbitMQ:消息保持“未确认"; 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
