[Data Grid Reactive] Aggregate Functions
Question
Forge component by Bruno Martinho

Hello,

thank you for adding the column group functionality. I was wondering if you are planning to support the aggration functions provided by wijmo in one of the future releases?

Is there a way one could set this property to the column config via wijmo API directly?

Thanks and best regards

Matthias



Hello @Matthias Schneider,

There is indeed a Wijmo's configuration on the columns that allow achieving the sum of all rows within a group. 

At the moment, this configuration is not available on the DataGrid component. I have already passed your question to the team as a possible suggestion for different approaches in the future.

-------------------------------------------------------

Right now, I would suggest the following workaround:

Please take into consideration that you will be using Wijmo's properties directly and that we didn't make all the necessary tests to ensure that it will work on all cases.


1) Create a new action in the Client Actions folder. Inside, you might want to add the following JavaScript:

> GridAPI.GridManager.GetGridById('Your Grid Id').getColumn('Binding of the column').provider.aggregate = 'Sum';

e.g.  Binding of the column -> "Sample_Product.Price";


If you try to do the same on one of the grids from the DataGrid documentation:


Hope this answer is useful.

Best regards,

Tiago Pereira

Hello @Matthias Schneider 

Can you explain a little better what aggregation functions are you referring? Any specific use cases that you can share so I understand better how to answer.

Thanks,

Bruno Martinho

Hello @Bruno Martinho,

thanks for your quick reply and sorry for beeing so wague.

I was referring to the Group aggregates Wijmo FlexGrid offers. What I would like to achieve is a sum of all rows within a group. In attached screenshot, I would like to have the sum of all numbers for the car model grouped by.

In wijmo documentation this could be as easy as giving the aggration function as a config for a column (last two columns):

// create group panel grid
var theGrid = new wjGrid.FlexGrid('#theGrid', {
    autoGenerateColumns: false,
    columns: [ // column definitions with aggregates
        { binding: 'id', header: 'ID', width: 60, isReadOnly: true },
        { binding: 'country', header: 'Country' },
        { binding: 'product', header: 'Product' },
        { binding: 'sales', header: 'Sales', aggregate: 'Sum' },
        { binding: 'expenses', header: 'Expenses', aggregate: 'Sum' }
    ],
    itemsSource: data
});

I thought it may be possible to change the wijmo column config in a js callback or maybe add this config parameter in the properties of the Outsystems column wrappers.

Thanks and best regards 

Matthias

Hello @Matthias Schneider,

There is indeed a Wijmo's configuration on the columns that allow achieving the sum of all rows within a group. 

At the moment, this configuration is not available on the DataGrid component. I have already passed your question to the team as a possible suggestion for different approaches in the future.

-------------------------------------------------------

Right now, I would suggest the following workaround:

Please take into consideration that you will be using Wijmo's properties directly and that we didn't make all the necessary tests to ensure that it will work on all cases.


1) Create a new action in the Client Actions folder. Inside, you might want to add the following JavaScript:

> GridAPI.GridManager.GetGridById('Your Grid Id').getColumn('Binding of the column').provider.aggregate = 'Sum';

e.g.  Binding of the column -> "Sample_Product.Price";


If you try to do the same on one of the grids from the DataGrid documentation:


Hope this answer is useful.

Best regards,

Tiago Pereira

May I know where is the trigger point to call the client action mentioned above?

What I ended up with was to put following code into the OnReady callback and it worked for me:

GridAPI.GridManager.Events.Subscribe(
     $parameters.GridID,
     ExternalEvents.GridEventType.Initialized,
     function (gridId, gridObj) {
         
         gridObj.getColumns().forEach(function(column) {
             if( "Number" == column.columnType){
                 column.provider.aggregate = 'Sum';
             }
         });
    }

);

I gave the grid a name and used the Widget id as input parameter for the function like so:

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.