Make GroupTable computes intermediate totals

Hi

Is it possible to plan at some point to make GroupTable computes intermediate totals ? For now it displays only the grand totals in the top row.

For instance in the screenshot below, on the “client” group line, the cells for which column has an agregation could display the result of agregation for the group.

image

Mike

Hi.
Could you please provide more information about your problem? Which version of the platform do you use? If it is possible, could you share the xml file of your screen or a small project in order to help us investigate the problem.

Have you tried updating the platform version up to 6.8? This functionality is a part of the out-of-the-box solution and this behaviour is default

image

Here the XML code for this table:

<groupTable id="foosTable"
                    aggregatable="true" aggregationStyle="TOP"
                    width="100%">
            <actions>
                <action id="create"/>
                <action id="edit"/>
                <action id="remove"/>
            </actions>
            <columns>
                <column id="name"/>
                <column id="date"/>
                <column id="price">
                    <aggregation type="SUM"/>
                </column>
                <column id="count">
                    <aggregation type="SUM"/>
                </column>
            </columns>
            <rows datasource="foosDs"/>
            <rowsCount/>
            <buttonsPanel id="buttonsPanel"
                          alwaysVisible="true">
                <button id="createBtn"
                        action="foosTable.create"/>
                <button id="editBtn"
                        action="foosTable.edit"/>
                <button id="removeBtn"
                        action="foosTable.remove"/>
            </buttonsPanel>
        </groupTable>

Hi Natalia,

Using 6.8.7, project in attachment reproduces the issue. The Sales group table is generated dynamically when the order line browser get refreshed.

The datasource is a CustomValueGroupDataSource generating set of KeyValueEntity on the fly.

As you can see in the screenshot below, if you group by a column, total aggregation on top is computed, but not intermediate ones.

image

testcuba2.zip (107.6 KB)

1 Like

Hi,

It seems that there is already issue for that Aggregation for GroupTable groups does not work if GroupTable is created programmatically · Issue #530 · cuba-platform/cuba · GitHub

Thanks Yuriy.

Seems the issue was created on 31-Aug-17, an idea when it will be fixed ?

Last months there was lot of improvements on ValueDataSource, it would be nice not to loose the momentum.

Mike

Hi

In the meantime I have found a workaround for people encountering the same issue.

Through debugging I found the grouping algorithm is split between WebAbstractTable and WebGroupTable. The first one manage an aggregationCells attribute, while the second uses a groupAggregationCells attributes.

And it seems there is some clash between the logic handling the two in the case of KeyValueEntity (I did not understand why though).

However, by extending WebGroupTable I was able to neutralise the aggregationCells property, letting the WebGroupTable uses its own one without interference.`

It fixes the issue, and it seems not having any impact on the standard case where GroupTable is used with entities that are not KeyValueEntity ones.
`
Here is how.

Extend WebComponentsFactory

public class ExtWebComponentsFactory extends WebComponentsFactory {

    @Override
    public Component createComponent(String name) {
        if(name.equals(GroupTable.NAME)) {
            try {
                return ExtWebGroupTable.class.newInstance();
            } catch (InstantiationException | IllegalAccessException e) {
                throw new RuntimeException("Error creating the '" + name + "' component instance", e);
            }
        }
        return super.createComponent(name);
    }

Override the bean in web-spring.xml

<bean id="cuba_ComponentsFactory" class="com.company.testcuba.web.components.ExtWebComponentsFactory"/>

Extend WebGroupTable

public class ExtWebGroupTable<E extends Entity> extends WebGroupTable<E> {
    protected Map<Object, Object> __aggregate(AggregationContainer container, AggregationContainer.Context context) {
        this.aggregationCells = null;
        return super.__aggregate(container, context);
    }
}`

I’ve seen no side-effects so far.

Mike

Hello, @michael.renaud

The issue is fixed. Fixes will be available in the next release.

Regards,
Daniil.

Great news, thanks Daniil

Michael