Aggregation of generated Column

Is it possible aggregating a generated column in table or TreeDataGrid ?

I have attached a sample app created in Studio 10 to illustrate this better as (104.1 KB)

Here is an example of data displayed in TreeDataGrid in this app.


You will see the column 2019 is not existing in the CustomerGroup Entity, rather created this column in the screen controller of CustomerGroupSales.

What I want is to update row "Customer Group BB with the value of customer Group BBA and BBB i.e. 1600+1722.5. Similarly, the the value of row B will be sum of value in row BC and BB

You will see what I have tried but seems like APIs used are not appropriate or it doesn’t work in this scenario!!

Thanks for your help.

As far as I know , it’s impossible.
Here is a similar question.

Thanks, but I am looking for the insight view of CUBA team and if there is any suggested implementation to solve this problem.

Hello @mortozakhan

Aggregation will work if a column will be bound with entity meta property.

Tell me if you need a demo.


Hi @tsarev
Thanks. Yes a demo will be appreciated. If you don’t have existing demo, you may use the one I have provided where add the amount field to the Entity.
Can such entity fields be added and removed at run-time so that it works dynamically?

In fact there is no any complex things to implement it. Just add transient meta property for an entity and setup aggregation. Please check a demo project: (90.3 KB)


Can such entity fields be added and removed at run-time so that it works dynamically?

Unfortunately no, you cannot change model scheme in runtime. You can add required set of fields and hide/show columns then.


Hi Daniil
Thanks for the demo app. I am wondering where did you write the code to sum the groups. I see you have selected agreegatable option in table xml but didn’t find any aggregation strategy for calculation. Thanks for any indication and where are those codes!

And will be this same for TreeDataGrid?

didn’t find any aggregation strategy for calculation

It’s defined for the “bounty” column in screen XML descriptor.

And will be this same for TreeDataGrid?

Grouping DataGrid is in our plans: GitHub


1 Like

Thanks. Sounds good that dataGrid is planned to have group option.

You gave examples of table group that will be very useful. How about treeTable and TreeDataGrid where the source of data is Hierarchical data?

An implementation for TreeTable should be the same, but DataGrid doesn’t support aggregation itself. Probably, it can be implemented with custom header or footer, but it requires a lot of code.

1 Like

Thank you. This implementation in GroupTable (and TreeTable) is very simple and straight-forward which is amazing! we don’t need to write those codes everywhere in the controllers.

For treeDataGrid I shall wait for the next enhancement that you planned.

Hi Daniil
I have a little bit different use case scenario for the aggregation. Let me explain it.
If you look at the attached demo app where you will find the column amountPd1 is representing sum value of sales from different customers which is calculated on the run. Since the hierarchical table is generated from CustomerGroup Table where there is no customers sales data, the sales data is calculated (see the controller of CustomerGroupSales). This calculation is working but what I am missing now is calculating for the customer group parent levels. How can we achieve that? (105.5 KB)

Have you tried to use our new API - Table.Column#setValueProvider?

GitHub issue

It seems that it’ll help you to solve the problem with aggregation and generated columns

Hi Daniil
No I haven’t use valueProvider. It will be very helpful if you can apply the approach in the same demo app.