Need a special offer?Find out if your project fits.
+

Calculated values not working due to unique name

Resolved
cwoo asked on August 4, 2021

Hi,
I have the grid set up as shown in https://jsfiddle.net/tyohxLgr/. If you look at the DisplayWeight (Custom) column, which is a calculated field, it doesn't show any value.
I have narrowed down the cause of the issue, where it seems that this is due to the uniqueName  "DisplayWeightCustomPivotmeasure_f47b1256dbef41548d567931abf0bac" specified for the calculated field. If I change the uniqueName to something else, the column displays fine.
Is there a limitation on how uniqueName could be specified?
Thanks.
 
Chen Woo.

3 answers

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster August 5, 2021

Hello, Chen,
 
Thank you for posting on our forum.
 
Flexmonster does not imply limitations on the unique name of the calculated values.
However, please note that calculated fields should not be mentioned in the JSON meta-object (first object of the array). This object only serves to define fields that exist in the data set.
After removing the mentioned field from the meta-object values are shown as expected: https://jsfiddle.net/flexmonster/mt4d3zx9/.
 
Please let us know if it helps.
 
Kind regards,
Illia

Public
cwoo August 5, 2021

Thanks for the response. It works after I removed the field from the meta-object as you suggested. By any chance this behavior was changed in recent releases? I asked this because we have been doing this in our codebase for a while, and I assume our QA would have caught this issue when they tested calculated field.
The next question I have is that how do i customize a field, especially calculated field using a function to display a value in a custom format? I have looked at https://www.flexmonster.com/api/customizecell/ but it wasn't clear to me on how to do this, specifically how do I target a specific cell.
Thanks.

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster August 6, 2021

Hello,
 
Thank you for your feedback. We are happy to hear it works for you now.
 
We want to note that this behavior was not changed in recent releases of Flexmonster. Calculated values should be separated from the dataset itself by the initial design.
 
Concerning calculated field customization, we suggest checking out our Number formatting and Conditional formatting features which support calculated values along with other measures in your data source. These features allow diverse formatting and conditional customization of cells.
If even more custom logic is required, you can use the customizeCell hook mentioned in your question. It is easy to target the desired cells by configuring conditions inside the customizeCell handler. We suggest checking out Live examples of the pivot table component using the customizeCell hook for reference. Basically, you want to use the data parameters passed to the handler to distinguish which cells should be formatted and how. The mentioned data parameter contains Cell Data Object which provides full information about the cell, including its actual value, hierarchy membership, identifiers, etc.

Please let us know if it helps.
Also, it would help us a lot if you could create a separate forum thread for unrelated questions in the future.
 
Best regards,
Illia

Please login or Register to Submit Answer