如何右对齐 Wicket 表格列中的单元格?
我想要一个 DataTable
的 PropertyColumn
右对齐。但是,如果我尝试将 new SimpleAttributeModifier("align", "right")
添加到单元格项目,它将添加到 td< 内的
span
/code>,而不是 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);
}
我可以通过 td
设置对齐方式吗?
I'd like to have a PropertyColumn
of a DataTable
right-aligned. But if I try to add a new SimpleAttributeModifier("align", "right")
to the cell item, it is added to a span
within the td
, rather than the td
itself.
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);
}
Can I get at the td
to set the alignment?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
诀窍在于,一旦将
td
添加到ICellPopulator
中,td
就是该项的父项,因此我们可以立即向其添加修饰符。The trick is that the
td
is the parent of the item as soon as it is added to theICellPopulator
, so that we can add a modifier to it straight away.