Refresh columnSummary calculation trigger

Tags: #<Tag:0x00007f8b1d8636c0>

Hi there,

i have trouble with the columnSummary plugin and my initial state of the table.
When initializing, i am loading all my data from the database into the table.
For the last row i am using the columnSummary with a ‘sum’. This works quite well overall, but initially it’s not calculating with my loaded data. After i change a data in one cell, it’s instantly calculating. But after loading i got all my data and the calculated value is 0.
I guess the problem is, that the columnSummary is set before my data is loaded, and after the data is loaded a trigger to recalculate is missing.

Is there some trigger i can set manually to make the row calculating? I tried hotTable.render() but this didnt make it.

Thanks for your help!

Hey @cgm.atlassian

Can you share a demo where the issue can be replicable? I think that we can use the afterChange hook, but maybe it will be better to replace the summaries with formulas, or native javascript - it depends on the example.

Hey Aleksandra,

thanks for the response.
Unfortunately i am not able to abstract an complete demo. I created one that’s working with the implemented columnSummary i am using: https://jsfiddle.net/yL910z2o/8/

With the predefined Data there are no issues.
In my case i’m working with angular and calling my getTableData()-method from the ngOnInit asynchronous.
Hopefully you can somehow imagine what the problem is without a complete demo or have an advice for me for a best practice in my case.

Thanks a lot!

Is an approach like this http://jsfiddle.net/ecLky1md/ meet your requirements? Please test it and let me know.

Hi,

sorry for the delay,
Can you explain me, how to use the formulas if i renamed my column and rowheaders? Do i use the actual text from the header or do i use the property from the data array?

Greetings
Paul

Hey Paul,

you always pass A1 for the first cell even if you do not have headers or rename them. If you need to change the name to something that will be easier to understand you can use our ranges declaration. Here is a demo https://jsfiddle.net/handsoncode/5jnt3p2w/

thanks a lot!

You’re welcome.