what I try to do is creating an (editable) column, that is bound to a property, render its value with a prefix found in another column (another property of the entity) when not in editable mode.
To be a bit more concrete. It’s an editable datagrid, the entity has a “currency” and an “amount” property. I want the “amount” column render like “EUR 123” when it is currently not edited.
The problem is, in the presentation function I don’t have access to other entity properties:
dataGrid.getColumnNN("amount")
.setRenderer(dataGrid.createRenderer(DataGrid.TextRenderer.class), value -> {
// No access to entity here .. :(
return value;
});
@Rimas Thanks for the direction. Until now I tried some things, but still no luck getting the whole thing correctly handled. Struggling with the editable part of the cell, but I still have some ideas that I can try based on your suggestion.
@michael.renaud Actually in this context, it is more a cosmetic task. Like you suggest, I was thinking of combining the currency and the amount into an embeddable entity CurrencyAmount, but I have got three “amounts” (base, vat, total) and it doesn’t feel right to store a currency for all three amounts, when only one is required. The column generator would be a good solution, but generated columns can’t be edited directly.
@michael.renaud Thanks for your input. I solved it otherwise now, by changing the requirement. That’s a good thing in this case, because the requirement wasn’t good as it was. Thank you anyways, I still got smarter with this thread and your answer.