I have a datagrid where I want have amount calculated from another table. as follows:
private void addTableValueColumns(){
// String currentYear="2019";
balanceSheetTreeDataGrid.addGeneratedColumn("amountPd2", new DataGrid.ColumnGenerator<AccountGroup, BigDecimal>() {
@Override
public BigDecimal getValue(DataGrid.ColumnGeneratorEvent<AccountGroup> event) {
return getTotalAmount( event.getItem());
}
@Override
public Class<BigDecimal> getType() {
return BigDecimal.class;
}
});
}
private BigDecimal getTotalAmount(AccountGroup accountGroup){
return dataManager.loadValue(
"select sum(e.amountDebit)-sum(e.amountCredit) from erp$AccountTranDetail e join e.account a " +
"where a.accountGroup.id= :accountGroup", BigDecimal.class)
.parameter("accountGroup", accountGroup.getId())
.optional().orElse(BigDecimal.ZERO);
}
The calculation from another table is done properly and updated in treeDataGrid but it seems aggregation is not supported as you can seen below. Is it the fact the treeDataGrid is not supproting aggregation yet or I am missing something?