Despite the COVID-19 outbreak, our team continues operating at full speed. We are always here to support and answer all your questions.

Feel free to reach out by filling this quick form.

Fill the form
Get Free Trial

How do i initialize formats and conditional objects?

Answered
Bilguun asked on September 11, 2020

Hello flexmonster team,

  1. How do i init formats and conditional objects when pivot created

if formats object can initialize able how can i naming?
every single field item will be different 
2. i need formats and conditions from getCondition(), getFormat()
if i can get those data’s i need save them 
Thank you

"formats": [
        {
            "name": "29mvnel3",
            "thousandsSeparator": " ",
            "decimalSeparator": ".",
            "decimalPlaces": -1,
            "maxDecimalPlaces": -1,
            "maxSymbols": 20,
            "currencySymbol": "$",
            "negativeCurrencyFormat": "-$1",
            "positiveCurrencyFormat": "$1",
            "nullValue": "",
            "infinityValue": "Infinity",
            "divideByZeroValue": "Infinity",
            "textAlign": "right",
            "isPercent": false
        }


5 answers

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster September 11, 2020

Hello, Bilguun,
 
Thank you for your question.
 
1. Concerning initialization of the number and conditional formatting on pivot creation.
If we understood your question right, the expected component behavior is loading the report with already defined conditions and formats.
If so, we recommend specifying conditions and formats in the report object and then loading it to Flexmonster. Please have a look: http://jsfiddle.net/flexmonster/ftq7de5w/.
 
To link the number formatting with a specific field, specify the same name both in the Format Object and in the element of the measures array:

"measures": [{
  "uniqueName": "Price",
  "format": "currency"
}],
"formats": [{
  "name": "currency",
  ...
}]

 
To apply conditional formatting to the chosen field, specify its unique name as a value of the measure property of the Conditional Format Object:

"conditions": [{
  "formula": "...",
  "measure": "Quantity",
  "format": {
    ...
  }
}]

 
For convenience, we suggest using UI to select the desired formatting and then save the report.
 
2. Concerning saving number and conditional formatting.
We want to explain that both number and conditional formatting rules are saved with a report. The report itself can be saved using the save API call or with a corresponding tab in the Toolbar.
 
In case number and conditional formatting, configurations need to be saved separately from the report, retrieve them using the mentioned getCondition and getFormat methods.
Next, received data can be saved manually.
 
We hope it works for you.
 
Kind regards,
Illia

Public
Bilguun September 12, 2020

Thank you for quick reply
please tell me is this 
“name”: “-tvn9ignsfxd00” when i save this format to database then call again this name will recognize? if did not recognize how do i set?

“formats”: [
        {
            “name”: “-tvn9ignsfxd00”,
            “thousandsSeparator”: ” “,
            “decimalSeparator”: “.”,
            “decimalPlaces”: 0,
            “currencySymbol”: “$”,
            “positiveCurrencyFormat”: “$1”,
            “nullValue”: “”,
            “textAlign”: “right”,
            “isPercent”: false
        }
    ],

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster September 14, 2020

Hello,
 
Thank you for your feedback.
 
We want to notice that the mentioned name property serves as a link between Format Object and the corresponding element of the measures array. For example:

"measures": [{
  "uniqueName": "Price",
  "format": "-tvn9ignsfxd00"
}],
"formats": [{
  "name": "-tvn9ignsfxd00",
  ...
}]

 
In case the configuration needs to be saved to the database, we recommend saving the whole report instead of separate Format Objects.
 
Otherwise, it is possible to save Format Objects without the name property specified. Next, apply formatting to the desired measure using the setFormat API call.
 
Detailed information about number formatting in Flexmonster can be found in our documentation.
 
We hope it works for you.
 
Kind regards,
Illia

Public
Bilguun September 15, 2020

Thank you Illia more i have more question
how to get only formatted measures currently i am consider this way it’s working but does not work properly

let measures = flexmonster.getReport().slice.measures;
let formatArr = [];
for(i=0; measures.length; i++;){
let format =    flexmonster.getFormat(measures[i].uniqueName)
formatArr.push(format);
}

it is doing for all measures if there is boolean or some comparison value i can do it properly could you help me improve  this way?
 
 

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster September 16, 2020

Hello,
 
Thank you for your feedback.
 
In case you require to ignore measures without any formatting specified, add the following condition:

let measures = flexmonster.getReport().slice.measures;
let formatArr = [];
for (i = 0; i < measures.length; i++) {
  if(measures[i].format) {
    let format = flexmonster.getFormat(measures[i].uniqueName);
    formatArr.push(format);
  }
}

It will check whether the measures array element has the format property.
Please note that default formatting (for all measures) will be ignored if the described approach is used.
 
We have also noticed that the provided code snippet serves to get an array of Format Objects instead of measures. In case it is the desired output, we suggest simplifying the construction to the following:

flexmonster.getReport().formats

Our team hopes it helps.
 
Regards,
Illia

Please login or Register to Submit Answer