15
Views
4
Comments
Solved
[Data Grid Web] [DataGrid] Add group total (sum) row in datagrid
Forge component by OutSystems R&D
41
Published on 14 Dec 2020
Application Type
Traditional Web

Hi all,

can someone help me how to add a total sum row in the bottom of the screen?

Like what here is said. https://www.outsystems.com/forums/discussion/48405/group-totals/

And here is explained by the makers https://www.grapecity.com/wijmo/demos/Grid/Aggregation/Belowthedata/purejs 

Did not exactly know how I can configure or script this


Thanks!

Staff
Rank: #483
Solution

Hello @Wieger Kloppenburg,

Thank you for bringing this topic to the discussion.

If I understood correctly, you just want to add the aggregates below the data just like Wijmo is doing right now - here.

I attached a sample to this message. You can take a look if you want to get a better look at what I am going to explain.

To do so, you will need to specify your grid's name (whatever you want to name it):

Then, in the preparation of the Web Screen, you will need to add a new Server action - in this case, you will need to use the Javascript action:


Now it's time to prepare the method addSumRow.

You can do that by adding the method into the Javascript of the Web Screen.

Check the code below:

var addSumRow = function(gridId){
    var gObj = GridOS.ComponentUtils.getGridObjectById(gridId);
    var grid = gObj.grid;
    grid.columnFooters.rows.push(new wijmo.grid.GroupRow());
    grid.bottomLeftCells.setCellData(0, 0, 'S');
};

This should be enough to customize your bottom row with the aggregation values from the numeric columns.

DataGridAddRowSum.oml

Rank: #2277

Hi @Wieger Kloppenburg, I don't know if I understand your question, but I had to create a subtotal on my  grid recently. Take a look: 


I did it using a Local Variable to store the subtotal amount and a "for..each" control to iterate the aggregate (source of the grid), incrementing the values. like this:

I Hope to help you!


Rank: #61509

Hi, 

What I want is like this:

The total sum row in the end of the table. So that it is still part of the table instead of another field in the page. Maybe someone will know how that can be done? And don't exactly know how I can script that. The makers of the wijmo grid give that example on their forum.

Staff
Rank: #483
Solution

Hello @Wieger Kloppenburg,

Thank you for bringing this topic to the discussion.

If I understood correctly, you just want to add the aggregates below the data just like Wijmo is doing right now - here.

I attached a sample to this message. You can take a look if you want to get a better look at what I am going to explain.

To do so, you will need to specify your grid's name (whatever you want to name it):

Then, in the preparation of the Web Screen, you will need to add a new Server action - in this case, you will need to use the Javascript action:


Now it's time to prepare the method addSumRow.

You can do that by adding the method into the Javascript of the Web Screen.

Check the code below:

var addSumRow = function(gridId){
    var gObj = GridOS.ComponentUtils.getGridObjectById(gridId);
    var grid = gObj.grid;
    grid.columnFooters.rows.push(new wijmo.grid.GroupRow());
    grid.bottomLeftCells.setCellData(0, 0, 'S');
};

This should be enough to customize your bottom row with the aggregation values from the numeric columns.

DataGridAddRowSum.oml

Rank: #61509