subtotal icon indicating copy to clipboard operation
subtotal copied to clipboard

Loading Pivot Configuration results in - Cannot read property 'value' of undefined (val = totalAggregator.value();)

Open DanEnglishby opened this issue 6 years ago • 2 comments

After saving the pivot configuration with any of the SubTotal.js renderers to cookie and trying to restore an error is produced.

Specifically line 567 in subtotal.js (val = totalAggregator.value();) error message: Cannot read property 'value' of undefined

The following JSON is what is being saved and attempting to be reloaded.

{"rendererOptions":{"localeStrings":{"renderError":"An error occurred rendering the PivotTable results.","computeError":"An error occurred computing the PivotTable results.","uiRenderError":"An error occurred rendering the PivotTable UI.","selectAll":"Select All","selectNone":"Select None","tooMany":"(too many to list)","filterResults":"Filter values","apply":"Apply","cancel":"Cancel","totals":"Totals","vs":"vs","by":"by"},"table":{}},"localeStrings":{"renderError":"An error occurred rendering the PivotTable results.","computeError":"An error occurred computing the PivotTable results.","uiRenderError":"An error occurred rendering the PivotTable UI.","selectAll":"Select All","selectNone":"Select None","tooMany":"(too many to list)","filterResults":"Filter values","apply":"Apply","cancel":"Cancel","totals":"Totals","vs":"vs","by":"by"},"derivedAttributes":{},"hiddenAttributes":[],"hiddenFromAggregators":[],"hiddenFromDragDrop":[],"menuLimit":9999,"cols":[],"rows":["READY_STATUS"],"vals":[],"rowOrder":"key_a_to_z","colOrder":"key_a_to_z","exclusions":{},"inclusions":{},"unusedAttrsVertical":85,"autoSortUnusedAttrs":false,"showUI":true,"sorters":{},"rendererName":"Table With Subtotal Heatmap","inclusionsInfo":{},"aggregatorName":"Count"}

As mentioned earlier, all of the standard PivotJS renderers still save/restore perfectly, it's just the new subtotal renderers that seem to have the issue.

DanEnglishby avatar Dec 19 '19 13:12 DanEnglishby

I am facing the same issue Cannot read property 'value' of undefined at line val = totalAggregator.value();

stephypeter avatar Feb 26 '20 12:02 stephypeter

made a comment re this on another thread - subtotal is using aggregate values already made by the main code, they are not currently being remade on refresh, hence they are undefined when using onrefresh - somehow subtotal has to remake a table-version of the aggregators first, then apply the subtotal styling after that...

Another issue I found is that some of my source values had decimal places, converting them to integers allowed the subtotal view to render correctly the first time.

OK think I worked out what was stopping it, I need to add the 'dataClass' back to the config object on refresh:

var dataClass = $.pivotUtilities.SubtotalPivotData;

and then later in onrefresh:

configobject["dataClass"] = dataClass;

Without that, the default dataClass was being created on refresh, which didn't have the Subtotal figures in it.

flowerbot avatar May 17 '21 23:05 flowerbot