Get Free Trial

How can I format boolean type for data source type JSON?

Rodrigo Arantes asked on July 12, 2021

Here is a data source config example:

datasource: {
type: "json",
data: [{
firstName: "User",
lastName: "Peixoto",
salary: 90000,
birthDate: "2020-12-31",
terminated: false,

Is there a data type boolean or formatting setting for it? Couldn’t find it in mapping object.

6 answers

Mykhailo Halaida Mykhailo Halaida Flexmonster July 13, 2021

Hi Rodrigo,
Thank you for posting your question.
Flexmonster does not provide a separate field type for boolean values. Instead, by default, they are recognized as regular string fields.
Please let us know if this helps.
Best regards,

Rodrigo Arantes July 13, 2021

Hi Mykhailo,
What is the best approach to instead of displaying “true” or “false” we display a friendly format like “Yes” or “No”


Mykhailo Halaida Mykhailo Halaida Flexmonster July 14, 2021

Thank you for your response.
The preferable approach in this situation is to modify the data source so that it already contains the “Yes”/”No”-value field you want to display.
However, it becomes easier if you’re using inline JSON data as your data source: you can set up a data preprocessor on the client-side that will add the necessary field to the data before feeding it to the pivot table. This way, the original data stays unchanged, but it is also displayed as necessary in your Flexmonster instance.
Here’s a quick example demonstrating this approach:
Hope this helps!

Rodrigo Arantes July 14, 2021

Hi Mykhailo,
That’s what I was trying to avoid. Wanted to see if there was something built-in related to data formatting.
Thanks for quick response 

Mykhailo Halaida Mykhailo Halaida Flexmonster July 15, 2021

Hi Rodrigo,
I just realized there’s a much simpler solution involving the customizeCell() API call.
It does not require you to modify the input data – instead, you simply rewrite the cell labels in the grid without affecting the underlying data.
Here’s a sample for demonstration:
Does this solution suit you better?

Rodrigo Arantes July 15, 2021

Hi Mykhailo,
That’s the one I went for. 

Thanks a lot for the follow up ?

Please login or Register to Submit Answer