I created a column using the below logic:
column = grid.addColumn("POLink", Component.class);
column.setRenderer(new ComponentRenderer());
column.setHeaderCaption("POLink");
column.setEditable(false);
column.setSortable(true); // Doesn't work here
BeanItemContainer<SupplierPortalReplOrder> gridContainer = new BeanItemContainer<SupplierPortalReplOrder>( SupplierPortalReplOrder.class,
new ArrayList<SupplierPortalReplOrder>() );
GeneratedPropertyContainer gpcontainer = new GeneratedPropertyContainer(gridContainer);
gpcontainer.addGeneratedProperty("POLink", new PropertyValueGenerator<Component>() {
@Override
public Component getValue(Item item, Object itemId, Object propertyId) {
// Code to create button or label, based on row of data, and return it/
}
});
grid.setContainerDataSource(gpcontainer);
grid.getColumn("POLink").setSortable(true); // Also doesn't work here, same error.
When I run it in the debugger, I get the following at column.setSortable(true)
: “java.lang.IllegalStateException: Can’t set column Column[propertyId:POLink] sortable. Container doesn’t support sorting by property POLink”. Formerly this was a normal text column, so it worked fine, allowing sorting. But I need to add a button to this column now, thus the code change. For now I can disable sorting for that column, but the underlying data supports sorting just fine. Any ideas on making this sortable when I use components?
I rarely call column.setSortable
directly. Normally I just let the lower level logic handle things based on the container, but I did just realize that anyplace I have buttons in the grid doesn’t let me sort by that column. I can sort by other columns. I never noticed this because these tended to be columns people wouldn’t sort by anyway.
I wonder if, in this case, I could somehow make a column sortable and clickable using another method? If the above request is not possible, maybe there is a work around. My ultimate goal is a column with, where appropriate. links that will open a PDF file in another browser tab. With buttons this is easy, but then I cannot sort.
Thanks.