We are using flexmonster (email@example.com) in our application. The charts are being build dynamically by the users based on the CSV data we feed to flexmonster. While trying to build the charts, in grid view, we use the format cell option to format columns in grid view.
While we are able set using “All values”, save it and when viewing next time, able to retrieve the format.
Is there a similar way to same the format cell applied to individual columns? We are using the getFormat() and setFormat() API calls. How to retrieve any format applied to individual columns?
The getFormat API needs a name of the column I think. It does not return the columns or fields to which any custom format has been applied. As the formatting is dynamic, we wouldn’t know which fields or columns have custom formatting. So currently, we are suggesting to use “All values”. But, there are cases where we need different formatting for different columns. We need ability to save these custom formats and apply them again when viewing data the next time on.
Please let us know if you need more information.
Thank you for posting your question.
Please note that you can set a single number format for all hierarchies in the grid by creating a format object with the
name: "" property. If, however, you would like to apply different number formats to different columns, you would need to create several format objects and assign specific names to each of them, for example:
currencySymbol: " pcs."
After this, you need to reference the defined formats by their
name property in the corresponding measures’ definitions inside the slice:
This way, you will be able to restore the current report configurations with the defined number formatting already active from the get-go. Check out the following JSFiddle sample illustrating this approach: https://jsfiddle.net/flexmonster/qxyse7n6/
In order to change the number formatting for a specific hierarchy, the
setFormat() API call needs to be used.
setFormat() receives 2 parameters:
format – the format object you want to apply to the hierarchy, and the
measureName – the name of the measure you want to apply the format to. Similarly,
getFormat() receives 1 parameter –
measureName, and returns the format applied to the hierarchy with the name equal to
Also, please note that if the
measureName is not specified in the mentioned API calls, the current default number formatting is returned or applied depending on the method.
Feel free to check out the following documentation page for a detailed overview of how number formatting works in Flexmonster: https://www.flexmonster.com/doc/number-formatting/
Please let us know if this helps.
Thanks for responding. The above makes sense if you want to set it programmatically.
What we are looking to achieve is to allow the end user to set the format for individual columns using the flexmonster object (Under formats -> format cell). We need an ability to save these custom formats set by user so that they can be reapplied when the user revisits the report.
Hope I am clear on what we are looking for.
Thank you for your swift reply.
The mentioned “Format cells” toolbar tab can actually be used to set formats for individual hierarchies as well. Please note that the necessary hierarchies have to already be active (selected to be displayed as measures in the Field List) – once they are, you can select them for formatting in the “Format cells” pop-up window dropdown.
In case the above still does not work on your side, we would appreciate it if you could send us your report configurations so that we can investigate this further.
Speaking of the ability to save the current formats, this can easily be achieved with the
save() API call, which is also the default handler for the “Save” toolbar tab. This API call lets you save the current report configurations (including formats) in their current state to a local JSON file, which can later be loaded back with the
open() API call to restore those configurations at any point in the future.
In addition to the above, it might also be helpful to track the changes in the report made by the user with the
reportchange event, in case this is something that would help you.
We hope this helps!
Thanks Mykhailo, we actually found a different way to do this based on our implementation but the above has helped. Marking as resolved to help others. Thanks