Datatable 如何右对齐Wicket表列中的单元格?

Datatable 如何右对齐Wicket表列中的单元格?,datatable,wicket,Datatable,Wicket,我希望将数据表的属性列右对齐。但是如果我尝试向单元格项添加一个新的SimpleAttributeModifier(“align”,“right”),它将被添加到td中的span,而不是td本身 public class AssetSizeColumn<T> extends PropertyColumn<T> { ... @SuppressWarnings("unchecked") public void populateItem(Item<ICellPopulato

我希望将
数据表的
属性列
右对齐。但是如果我尝试向单元格项添加一个新的SimpleAttributeModifier(“align”,“right”)
,它将被添加到
td
中的
span
,而不是
td
本身

public class AssetSizeColumn<T> extends PropertyColumn<T> {
...
@SuppressWarnings("unchecked")
public void populateItem(Item<ICellPopulator<T>> item, String componentId, IModel<T> rowModel) {
    IModel<Long> model = (IModel<Long>) createLabelModel(rowModel);
    Component label = new Label(componentId, model.getValue().toString());
    label.add(new SimpleAttributeModifier("align", "right"));
    item.add(label);
}
公共类AssetSizeColumn扩展了PropertyColumn{
...
@抑制警告(“未选中”)
公共void populateItem(项、字符串组件、IModel rowModel){
IModel模型=(IModel)createLabelModel(rowModel);
组件标签=新标签(componentId,model.getValue().toString());
添加(新的SimpleAttributeModifier(“对齐”、“右”);
添加(标签)项;
}

我可以在
td
设置对齐方式吗?

诀窍是,
td
一旦添加到
ICellPopulator
中,它就是项目的父项,这样我们就可以直接向它添加一个修改器

public void populateItem(Item<ICellPopulator<T>> item, String componentId, IModel<T> rowModel) {
    IModel<Long> model = (IModel<Long>) createLabelModel(rowModel);
    Component label = new Label(componentId, model.getObject().toString());
    item.add(label);
    label.getParent().add(new SimpleAttributeModifier("align", "right"));
}
public void populateItem(项项项、字符串组件ID、IModel行模型){
IModel模型=(IModel)createLabelModel(rowModel);
组件标签=新标签(componentId,model.getObject().toString());
添加(标签)项;
label.getParent().add(新的SimpleAttributeModifier(“align”,“right”));
}