We have updated Flexmonster Software License Agreement, effective as of September 30, 2024. Learn more about what’s changed.

Date field with null and empty string not formatting the dates column

Answered
Akshaya shet asked on March 8, 2022

Scenario 1: If JSON data first object date property null value/ empty string present then date formatting not working

[
{
"Date": null,
"Event": "Concert",
"Price": 56
},
{
"Date": "2013-10-28T00:00:00.000Z",
"Event": "Performance",
"Price": 34
},
{
"Date": "2013-10-18T00:00:00.000Z",
"Event": "Cinema",
"Price": 10
}
]

Screenshot:
https://prnt.sc/MWaozuunr7Tk
Ex:
https://jsfiddle.net/zqnc5k2p/5/
 
Scenario 2: If null or empty string present after first object date formatting works.
Screenshot:
https://prnt.sc/Xbql3yCAc2nC
Ex:
https://jsfiddle.net/zqnc5k2p/7/
 
In our project, we have dynamic date columns (more than 30 cols )where we cannot specify the date type to each date column. Due to this issue(Scenario 1) we are not able to format the dates.
Kindly please look into it and suggest any solution for this.
 

2 answers

Public
Maksym Diachenko Maksym Diachenko Flexmonster March 8, 2022

Hello, Akshaya!

Thank you for writing to us.

The described behavior is caused by Flexmonster type definition logic. If the type isn`t specified, Flexmonster automatically assigns a type for a certain field according to a first value. Empty string and null values can not be recognized as dates, as the result date formatting does not work. 

This issue can be solved by using a mapping for the explicit type definition, as it is shown on this example: https://jsfiddle.net/flexmonster/7xsq4ozd/.

Hope you will find this answer helpful.

Best Regards,
Maksym

Public
Akshaya shet March 8, 2022

Thanks for the quick reply.
Thanks for providing the solution to this issue.
 

Please login or Register to Submit Answer