我真的需要你帮助解决一个 Wicket 口问题。
我想向 PropertyColumn 中的所有行添加工具提示(通过鼠标悬停)。但我该怎么办呢?我见过带有 Abstractcolumn 的解决方案。但我必须使用 PropertyColumn,因为我需要 propertyExpression 而不需要 sortProperty。
最佳答案
一种方法是修改DataTable
,如下所示:
add(new DefaultDataTable("wicektid", null, null, 10) {
@Override
protected Item newCellItem(String id, int index, IModel model) {
Item item = super.newCellItem(id, index, model);
item.add(AttributeModifier.replace("title", "Your Title"));
return item;
}
@Override
protected Item newRowItem(String id, int index, IModel model) {
Item item = super.newRowItem(id, index, model);
item.add(AttributeModifier.replace("title", "Your Title"));
return item;
}
});
如果您希望在整行或单个单元格上显示工具提示,您可以在此处进行控制。
如果您想在某些列中执行此操作,您可以覆盖该列中的 populateItem
,如下所示:
add(new PropertyColumn<>(){
@Override
public void populateItem(Item<ICellPopulator<T>> item, String componentId, IModel<T> rowModel) {
super.populateItem(item, componentId, rowModel);
}
});
关于java - Wicket - 将工具提示添加到 PropertyColumn 中的每个单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18234535/