Grid Footer Average

Hi Radzen Dev Team,
Do you have any working samples for getting the datagrid footer calculations such as column averages?

Can this be programmed only using the client side datagrid events, without having to load data against the backend? I mean, traverse the grid data and do the calculations from the client, after editing any of the datagrid cells?

Thanks for the great help
Regards

Hi @Jose_Carrillo,

You can check the Footer Template section from our documentation.

You can calculate the average like this:

The Value of the average property is:

${getOrderDetailsResult.map(i => i.Quantity).reduce((x, y) => x + y) } / ${getOrderDetailsResult.length}

And then use it in the DataGrid:

Thanks Atanas , It worked!

I have a column with only 2 possible values, 0 or 100 and I want to calculate the AVERAGE for the entire column. This method only seems to calculate the average for just the page being displayed. How do I get the calculation for the entire column and not just the displayed page

Thank you

The example linked above shows how to calculate it over all items.

Another option is to use a custom server method.

Thank you, that works for the SUM of the column, but I am trying to return the AVERAGE of the column and it should calculate the AVERAGE based on any filtering applied to the datagrid. The average of all records would be displayed and then recalculated as any filters are applied.

Thank you

The approach remains the same. You can search online how to calculate the average of a JS array.