Look up GWT CellTable header style/s?

[亡魂溺海] 提交于 2019-12-13 18:56:53

问题


How can TH style name/s of a GWT CellTable's heading be looked up programatically?

I have looked at the Client Bundle documentation but it isn't immediately obvious to me how it all fits together. Thanks.


回答1:


Not sure exactly what you want to do when accessing the TH style names.

If you want to override the standard css style of a celltable header, here are some of the css styles you can override to change the Look and Feel of the component.

.cellTableFirstColumnHeader {}

.cellTableLastColumnHeader {}

.cellTableHeader {
      border-bottom: 2px solid #6f7277;
      padding: 3px 15px;
      text-align: left;
      color: #4b4a4a;
      text-shadow: #ddf 1px 1px 0;
      overflow: hidden;
 }

.cellTableSortableHeader {
  cursor: pointer;
  cursor: hand;
}

.cellTableSortableHeader:hover {
  color: #6c6b6b;
}

.cellTableSortedHeaderAscending {

}

.cellTableSortedHeaderDescending {

}

Here is the complete list of styles for cellTables CellTable.css

Now if you want to access you header programmatically, you can use this solution to get the TableSectionElement corresponding the the Header of your table. Then you can access the row, then the cells, and lookup for their styles I guess.

Last thing if you want to override the header style, maybe you can use the following method when adding your column to your table

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

Then create your Header or use a TextHeader for example then set your style on it before adding it to the table using

public void setHeaderStyleNames(String styleNames)

Example

TextHeader textHeader = new TextHeader("headerTitle");
textHeader.setHeaderStyleNames("my-style");
myTable.addColumn(myColumn, textHeader);



回答2:


Easy solution:

import com.google.gwt.user.cellview.client.CellTable.Resources;

private String getCellTableHeaderStyle() {
    Resources res = GWT.create(Resources.class);
    return res.cellTableStyle().cellTableHeader();
}


来源:https://stackoverflow.com/questions/7598956/look-up-gwt-celltable-header-style-s

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