[FORMULAS] Sum over nestedRow group in Angular

Tags: #<Tag:0x00007efc65619ac8>

Hi,

im using Handsontable with nestedRows in Angular and in want to calculate the sum over each group. I found the following example in the documentation: Tutorial: Summary Calculation. Now I copied the example to my code and adjusted it to typescript and used the Angular Wrapper to get my hot-Instance. Now the particular code where my issue comes looks like this:

const nestedRowsPlugin = this.hotRegisterer.getInstance(this.hotId).getPlugin('nestedRows');
const getRowIndex = nestedRowsPlugin.dataManager.getRowIndex.bind(nestedRowsPlugin.dataManager);

And i get the following error:

error TS2339: Property ‘getRowIndex’ does not exist on type ‘void | DataManager’.

Can you help me with this issue?
Thanks

Hey @steffen.froehlich

The summaries should be attached via columnSummary array of objects, like in the demo below
https://jsfiddle.net/7h2gdfqt/
We should not use any methods outside the official API.

Hi Aleksandra,
yes you’re right, but my problem is, that i use nested rows and i want to calculate the sum over each group of children. And in the documentation i linked is an example which does what i want to do, but i don’t get it to work in my angular app. Do you have any example which shows me how i can get the data of a group of children and then use the columnSummary to display the sum of it?

Please share a demo with the latest progress. I’ll check what can be done.

I am using this example from your documentation: https://jsfiddle.net/c5w98myr/
And I want to use it exactly like that in my angular app. But instead of

var nestedRowsPlugin = this.hot.getPlugin(‘nestedRows’);

I use the AngularWrapper to get my Handsontable instance. But then in the next line

var getRowIndex = nestedRowsPlugin.dataManager.getRowIndex.bind(nestedRowsPlugin.dataManager);

The function getRowIndex throws an error saying:

error TS2339: Property ‘getRowIndex’ does not exist on type ‘void | DataManager’

Do you have any idea where this could come from?

Please check if this works for you https://jsfiddle.net/r0nep4q7/

In between I got it to work :slight_smile: It was not an issue with Handsontable, I messed up with JS scopes. Thanks for your help!

Another question if I may: I have a big table (more than 40 columns) and column summary won’t work for the whole table. Will the performance be better if I use formula?

Will the performance be better if I use formula?

I should be better if you use formula (the new formula) https://github.com/handsontable/handsontable/issues/6466
It is a work in progress and the core is ready - we just need to make it work with Handsontable.