I realize that this answer is probably too late for your purposes, but it may help someone looking for the same question. Here's the code that I use:
private void centerCheckBox(final ColumnConfig<Pet, ?> columnConfig) {
final int leftPadding = (columnConfig.getWidth() - 12) / 2;
final String styles = "padding: 3px 0px 0px " + leftPadding + "px;";
final SafeStyles textStyles = SafeStylesUtils.fromTrustedString(styles);
columnConfig.setColumnTextStyle(textStyles);
}
In addition to calling this method for each checkbox after the ColumnConfig
is created I also call it for each checkbox column in the ColumnWidthChange
event handler (the event handler is added to the ColumnModel
). Here's my code for the column width change handler (note: I add each checkbox column config to a set when I create the ColumnConfig
instances):
columnModel.addColumnWidthChangeHandler(new ColumnWidthChangeHandler() {
@Override
public void onColumnWidthChange(final ColumnWidthChangeEvent event) {
final ColumnConfig<Pet, ?> petColumnConfig = columnConfigList.get(event.getIndex());
if (_checkBoxSet.contains(petColumnConfig)) {
centerCheckBox(petColumnConfig);
_grid.getView().refresh(true);
}
}
});