USE CASE: We have a List deployed in a form using fd.control. This list has a column (ValueFSD) calculated as a multiplication of two other columns in the same list. When we render the List in the form, we would like to sum all the rows and place the total at the top (if not, then the bottom) of the grid for that column.
ATTEMPT SO FAR: We reviewed the Kendo Grid Control documentation and decided that using the footerTemplate and/or the headerTemplate method might work. We tried many variants of the code but no success.
Dear @vhancock,
Working with calculated columns is difficult for a reason - they do not store an actual value, just the formula, and the value has to be retrieved from the original fields that are part of calculation.
Moreover, List or Library control doesn't actually store any values unlike Data Table, all the values in List or Library control are retrieved as necessary - meaning you cannot even get all the values out of the control, if you have multiple pages of items.
To achieve what you want to achieve, you will need to use pnp-js to retrieve values from the source list, get values of fields that are used in calculated columns, do the same calculation with JavaScript, and then sum the results.
That's the only way I can think of summing calculated columns, not the easiest task by any means. Possible, sure, but much trickier than just summing a Number/Currency column.
Thank you Nikita, really appreciated. That is pointing me in the right direction.I will continue to work on this and if I am successful, will post the solution in this post.
By the way, have I told you recently how amazing your product is? It has completely transformed the user experience in SharePoint. Not only beautiful forms, but instantaneous actions with JS Code, unlike PowerAutomate that takes minutes to execute.
Dear @vhancock,
It's a pleasure to hear it! Now, if you really need to work the way you've described - we can help get there, but probably one step at a time. I would break it down as following:
Get the items with PNP-JS, configure filters to match your List or Library control view
Get field values used in calculated fields, and do the same calculation with JavaScript
Combine all values to get the sum of calculated fields
Now, I would recommend starting with step 1 and going to step 2, 3 as you progress, and we can help debug the code if you run into any issues or not sure what to do!
By the way, if you're enjoying the product, please, consider leaving a review or even better - contact support@plumsail.com to share your story, like others have done before, we really appreciate such feedback and in return could further help with code refactoring or custom solutions you might need!
Dear @vhancock,
I've run some basic tests with PNP-JS and it does seem like the calculated value is actually stored in items, so it doesn't need to be re-calculated, that's my bad: