How do I programmatically get info about a CellTable's headers?

自作多情 提交于 2019-12-24 03:52:57

问题


I'm using GWT 2.4. I have a com.google.gwt.user.cellview.client.CellTable widget, but I'm having trouble figuring out a programmatic way to get the String headers after the widget is constructed. I add column data like so ...

tableWidget.addColumn(column, header); 

where column is a com.google.gwt.user.cellview.client.Column object and header is a String. how can I get the header from either the column or cell table objects?


回答1:


For using protected method you can create a custom class, like this:

public class CustomCellTable extends CellTable {

    /* some code... */

    /* Method for access to header */
    public TableSectionElement getHeadElement() {
          return this.getTableHeadElement();
    }

    /* some code... */

}



回答2:


Try to use getTableHeadElement() method of com.google.gwt.user.cellview.client.CellTable. See documentation.




回答3:


If you want to have more control on your header, maybe you can use the following method when adding your column to your table. Thus you could keep a pointer on your header to do whatever you want on it.

public void addColumn(Column<T, ?> col, Header<?> header)

Then create your own Header or use a TextHeader for example.

TextHeader textHeader = new TextHeader("headerTitle");
myTable.addColumn(myColumn, textHeader);

But if the goal is to verify that the widget is being created properly I guess that it is GWT responsibilityto do that. I do not see the point of testing GWT behavior. It is already done by GWT. Of course there might be some bugs that you can find.

see other post here also if your want to check or override some css style : look-up-gwt-celltable-header-style-s



来源:https://stackoverflow.com/questions/8189991/how-do-i-programmatically-get-info-about-a-celltables-headers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!