English 中文(简体)
如何将 cs 类添加到单元格表部件( GWT) 第一列?
原标题:How to add a css class to the first column of a CellTable widget (GWT)?

我在 GWT 中使用了细胞表部件 。

我想更改第一列中每条文字的字体大小。 方法 < code> addcolumnStyleName 不符合我的需要, 因为它将该类添加到 < code> colgroup 标签中; 此标签只处理部分 cs, 我无法更改一个 colgroup 的字体属性( 它在文本上没有发生) 。

所以,我想在第一列的每个 < code> td 上添加一个类, 但无法找到一个轻松的方法来做到这一点 。

设置纵列的RowStyles之类的东西是好的,但是它并不存在...

你有做这种事的暗示吗?

<强度>EDIT:我使用GWT 2.3,而不是2.4(其方法设置为CellStyleNames)

最佳回答

它的简单性就如同在 sseCellStyleNames 上调用 Column 实例。

问题回答

我终于明白了,但我对这个解决方案不太满意。对于这么简单的任务来说,它有点含糊。我愿意接受任何其他建议。

我的方法就是创建一个新的细胞和一个新的专栏:

private class KeyColumn extends Column<SimpleLegendItem, String> {

    public KeyColumn() {
        super(new KeyCell());
    }

    @Override
    public String getValue(SimpleLegendItem item) {
        return item.getKey();
    }       
}

private class KeyCell extends AbstractCell<String> {

    @Override
    public void render(com.google.gwt.cell.client.Cell.Context context, String value, SafeHtmlBuilder sb) {
        sb.appendHtmlConstant("<span class="" + tableResources.cellTableStyle().box() + "">");
        sb.appendEscaped(value);
        sb.appendHtmlConstant("</span>");
    }       
}

为了简化例子,我故意不使用模板。





相关问题
Refresh the UI in gwt

I have created some custom composite widget, which listens to an events (in my case loginEvent). Once the event is caught the state of the widget changes so as the way it should look (in my case I ...

How to create a development/debug and production setup

I recently deployed inadvertently a debug version of our game typrX (typing races at www.typrx.com - try it it s fun). It was quickly corrected but I know it may happen again. After digging on ...

GWT error at runtime: ....style_0 is null

My code works fine in IE 8, but on firefox 3.5, the javascript fails to load. I used firebug to figure out why, and the error I get is (GWT detailed mode) My suspicion is that some style is not ...

GWT s hosted mode not working

I ve been stumped for a while trying to figure out why my GWT demo app isn t working in hosted mode so I went back and downloaded the Google Web Toolkit again, unzipped it and simply went to the ...

How to disable Google Visualizations Tool Tips?

Does anyone know how to disable the tool-tip boxes that popup when a Google Visualizations chart is clicked (Selected)? Following the sample code at Getting Started with Visualizations, the "...

GWT 2 CssResource how to

I have a GWT 1.7 application and I want to upgrade it to GWT 2 Milestone 2. The application uses 2 big external CSS files. In GWT 1.7 I had a public folder and put both the CSS files in the folder and ...

热门标签