Skip to content

Instantly share code, notes, and snippets.

@amahdy
Created January 24, 2016 13:28
Show Gist options
  • Save amahdy/f8383e8467dfc2e44425 to your computer and use it in GitHub Desktop.
Save amahdy/f8383e8467dfc2e44425 to your computer and use it in GitHub Desktop.
BeanItemContainer<P> container = new BeanItemContainer<P>(P.class, ps);
final GeneratedPropertyContainer gp = new GeneratedPropertyContainer(
container);
gp.addGeneratedProperty("Col1", new PropertyValueGenerator<String>() {
@Override
public SortOrder[] getSortProperties(SortOrder order) {
return new SortOrder[] { new SortOrder("Col1", order
.getDirection()) };
}
@Override
public String getValue(Item item, Object itemId, Object propertyId) {
return apply(((P) itemId).getVal());
}
@Override
public Class<String> getType() {
return String.class;
}
});
container.setItemSorter(new DefaultItemSorter() {
@Override
public void setSortProperties(Sortable container,
Object[] propertyId, boolean[] ascending) {
super.setSortProperties(gp, propertyId, ascending);
}
});
grid.setContainerDataSource(gp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment