Edit 2 updated this again because the OP's question is finally clear: how do you set a style on a particular cell of the header table of a PagingScrollTable?
PagingScrollTable scrollTable = ...
scrollTable.getHeaderTable().getCellFormatter().addStyleName(row, column, "myStyleName");
where row and column are 0-based integers indicating which cell of the header table to set the style on.
Edit updated this to explain how to set a style on the header, since the person asking the question clarified that's what they want.
If you want to add a style to the header of a PagingScrollTable, just do this:
PagingScrollTable scrollTable = ...
scrollTable.getHeaderTable().addStyleName(row, "myStyleName");
and then put in a CSS rule for myStyleName to set the cursor to whichever one you want, like so:
.myStyleName {
cursor: default;
}
Note that the reason why the cursor is a pointer is that clicking on a column header in a PagingScrollTable will sort the table by that column. To disable that, call scrollTable.setSortPolicy(AbstractScrollTable.SortPolicy.DISABLED
Original answer This will add a style to a column in the body of the table, but not the header or footer:
Since you mention ColumnDefinition
I presume you're talking about PagingScrollTable
. In that case, the way to add a CSS style to a cell is in the CellRenderer
for the cell. Once you've got a ColumnDefinition
, do something like this:
CellRenderer<YourRowType, String> cellRenderer = new CellRenderer<YourRowType, String>() {
public void renderRowValue(RowType rowValue, ColumnDefinition<RowType, String> columnDef,
TableDefinition.AbstractCellView<RowType> view) {
view.setHTML(value);
view.addStyleName("myStyleName");
}
};
columnDefinition.setCellRenderer(cellRenderer);
You'll have to change the type parameters of CellRenderer<YourRowType, String>
appropriately, but that's more or less how to do it.