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

Customize number column with string issue

Answered
Felix Tan asked on February 20, 2023

Dear Flexmonster,
I have a column which set as datatype: number. and i have a 3 different type of data which is numbers, masked data(****), and NULL value. sample data as below:
1. 1000
2. ****
3. NULL value (nullValue: "-")

I notice that flexmonster will change a non-number data into a NULL/blank value. so i have used customizeCell to make it show on the screen as what we saw in the data source.
Sample code:
flexmonster.customizeCell((cell, data) => {
if (data.hierarchy &&
   data.type == "value" &&
   data.hierarchy.type=="number" && isNaN(data.value))
{
  cell.text = "****";
}
});
However, i have encounter an issue where customizeCell not able to differentiate between **** and NULL value. Any suggestion on customizing the cell or any other method to solve this issue?
My aim is to show the data similar as from data source (1000,****,-), kindly refer the attachment for more details

Attachments:
masked.PNG
NULL.PNG

3 answers

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster February 20, 2023

Hello, Felix!
 
Thank you for contacting us and for the details about your case.
 
We have noticed on the screenshots that you are using a flat grid without calculating the totals. For such a case, we kindly recommend setting the data type of the "Basic Salary" to string to achieve the desired behavior. This can be done inside the report using mapping property:

report: {
    dataSource: {
        //other connection properties
        mapping: {
            "Basic Salary": {
                type: "string"
            }
        }
    },
    //other report properties
}

We have prepared a JSFiddle example for reference: https://jsfiddle.net/flexmonster/hanm4wby/.
 
Please let us know if the suggested approach works for your case.
 
Kind regards,
Solomiia

Public
Felix Tan February 21, 2023

Hello Solomiia,

I would like to remain its feature to calculate (sum etc.) and doing some pivot, therefore i mapped it to become a number type. However i am facing the issue mentioned before. 

Please advise us whether any other approaches we can use.

Regards,
Felix

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster February 22, 2023

Hello, Felix!

Thank you for getting back to us.
 
Kindly note that Flexmonster doesn't support mixed datatypes, so all non-numeric values, including null ones, are mapped as NaN for the field with a number datatype while preprocessing the data. Therefore, null and "****" are the same fields with NaN value inside the customizeCell() function.
 
Hope it helps.
Feel free to contact us in case of any other questions.
 
Regards,
Solomiia

Please login or Register to Submit Answer