Get Free Trial

Flat Form layout removes zeros from text

Re-Open
Adam Plumridge asked on September 21, 2020

Hello,
If I have zeros at the start of text, they are removed when I switch to flat form view. I have attached a picture with highlighted values. When in classic form ‘Product Name’ is 00694.0006 however when I switch to flat form ’00’ are removed from product name. I need that the text stays the same in all layout views and also in all exports.
Can anyone please have a look and provide me a solution for this? Thank you.
I am using Flexmonster v.2.8.12 for JSON data sources.
The issue can be reproduced on the following page:
https://dev551.mestec.net/

Username: **********
Password: **********

Attachments:
Flexmonster grid.png

10 answers

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster September 22, 2020

Hello,
 
Thank you for reaching out to us.
 
In case the field’s data type is not explicitly defined, Flexmonster tries to infer its type automatically. In its turn, JavaScript allows defining numbers with leading zeros. As a result, when placing the “Product Name” hierarchy to measures or switching to the flat form, the field’s numeric value is displayed instead of a string.
 
We suggest defining the data type of the “Product Name” field as string. It is achievable using the Mapping property of the Data Source Object.
Please see the JSFiddle demonstrating the described approach.
 
Please let us know if it works for your case.
Do not hesitate to contact us in case any further questions arise.
 
Regards,
Illia

Public
Adam Plumridge November 1, 2021

Hi Illia,
We are using the following function to update the mapping but seems it didtn work.
jsonData is the dataset query from our database in json format.
ScrapAnalysisPivot_pc004c380_6450_474b_9166_ccf8aac4191c_Pivot.updateData(
{ data: jsonData, “dataSource”: { “mapping”: {“PRODUCT”:{ type: “string” }}}
});
 

Attachments:
Untitled.png

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster November 2, 2021

Hello, Adam,
 
Thank you for contacting us.
 
Kindly note that the first argument of the updateData API call has the same structure as the DataSourceObject. It contains the data and mapping properties. So the code snippet will look like this:

updateData({ 

   data: jsonData, 

   mapping: {

      "PRODUCT": { type: "string" }

   }

});

Please see the example on the following JSFiddle: https://jsfiddle.net/flexmonster/s8mLnjkv/
 
We hope it helps. You are welcome to write to us in case further questions arise.
 
Kind regards,
Nadia

Public
Adam Plumridge November 3, 2021

Hi Nadia,
It works fine for me after updating the parameters.
However, ‘PRODUCT’ becomes the only metric appear in the grid and other datasource fields are missing.

var hasDoneInitialLoad = false;
var previousSlice = null;
var previousDataNull = null;
AnalysisDS_pc2428f0c_8d0f_4a74_be7c_ff8719f17037.bind(‘change’,function(){
var jsonData = AnalysisDS_pc2428f0c_8d0f_4a74_be7c_ff8719f17037.data().toJSON();
var noData = false;
if(jsonData.length==0){
jsonData=[{ NODATA:null }];
noData = true;}
if(noData === true && hasDoneInitialLoad === true){
var currentMeasures = ScrapAnalysisPivot_pc2428f0c_8d0f_4a74_be7c_ff8719f17037_Pivot.getMeasures();
var currentRows = ScrapAnalysisPivot_pc2428f0c_8d0f_4a74_be7c_ff8719f17037_Pivot.getRows();
previousSlice = { rows: currentRows, measures:currentMeasures};
}
ScrapAnalysisPivot_pc2428f0c_8d0f_4a74_be7c_ff8719f17037_Pivot.updateData({ data: jsonData,mapping: {“PRODUCT”:{ type: “string” }}
});
if(hasDoneInitialLoad === true && previousDataNull === true)
ScrapAnalysisPivot_pc2428f0c_8d0f_4a74_be7c_ff8719f17037_Pivot.runQuery(previousSlice);
if(hasDoneInitialLoad === false && noData === false){
ScrapAnalysisPivot_pc2428f0c_8d0f_4a74_be7c_ff8719f17037_AddSlice();
hasDoneInitialLoad = true;
}
if(noData === true)
previousDataNull = true;
else
previousDataNull = false;
});
function ScrapAnalysisPivot_pc2428f0c_8d0f_4a74_be7c_ff8719f17037_AddSlice(){
var slice = {
rows:[
{ uniqueName : ‘MATERIALREASONNAME’ , caption : ‘Material Reason Name’ },
],
measures:[
{ uniqueName : ‘QTY’ , caption : ‘Quantity’ ,aggregation : ‘sum’},
],
};
ScrapAnalysisPivot_pc2428f0c_8d0f_4a74_be7c_ff8719f17037_Pivot.runQuery(slice);
}

 
 
 

Attachments:
Screenshot_1.png

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster November 4, 2021

Hello, Adam,
 
Thank you for your response.
 
Could you please tell us which version of Flexmonster you use? In older versions of Flexmonster, the mapping required defining all the fields to include them into the component. We changed the described behavior in the newer versions. So you can solve your issue by simply updating Flexmonster to the latest version
 
Please let us know if it works for you. Feel free to contact us if other questions arise.
 
Kind regards,
Nadia

Public
Adam Plumridge November 4, 2021

Hi Nadia,
We are on ‘February 2021 (v. 2.8.27)’ refer to the flexmonster.js file, will updating to v2.9 solve the issue?

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster November 5, 2021

Hello, Adam,
 
Thank you for your response.
 
Updating to the latest version will solve your issue. The mapping behavior was updated in May 2021 (v. 2.8.32).
 
We hope it helps. You are welcome to write to us in case further questions arise.
 
Kind regards,
Nadia

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster November 12, 2021

Hello, Adam,
 
Hope you are doing well.
 
Just checking in to ask if you found the solution helpful. 
 
We will be glad to hear your feedback.
 
Kind regards,
Nadia

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster November 19, 2021

Hello, Adam,
 
Hope you are doing well.
 
We were wondering if the solution helped you. Looking forward to your feedback.
 
As always, feel free to write to us in case further questions arise.
 
Kind regards,
Nadia

Public
Adam Plumridge 7 days ago

Hi Nadia,
The updated version fixed the issue.
Thanks.

Please login or Register to Submit Answer