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

Date format when field is null

Answered
Rodrigo asked on July 6, 2020

Hi Team,
Not sure if this was reported or there is another way of doing it, but I cannot have dates columns formatted properly when the first item in the object array is null. I left on fiddle (https://jsfiddle.net/eqf327az/1/) this example to try to reproduce it. Whenever the first item has a value, then the format works properly. Otherwise, it shows as string. Is there any advice? 
 
Thank you,
 
Rodrigo 

3 answers

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster July 6, 2020

Hello, Rodrigo,
 
Thank you for reaching out to us.
 
Our team would like to explain that the reason for such a behavior is the fact that Flexmonster tries to identify the data type of the field automatically in case it is not explicitly specified. Being set to null, the first occurrence of the "dateTest" hierarchy leads to a false result.
 
We recommend using the mapping object in order to predefine data types of selected hierarchies and avoid such behavior.
 
We have prepared an example demonstrating using the mentioned object.
Detailed information about the mapping object and its properties can be found in our documentation.
 
Please let us know if it works for your case.
Do not hesitate to contact us in case further assistance is needed.
 
Regards,
Illia

Public
Rodrigo July 7, 2020

Hi Illian,

Thank you for the response. Generally, I was trying to avoid mapping, from what I saw here, if I map one property, I have to map all the other ones I want to display, right? Just inserting the columns in the slice is not enough, is that correct?
Just saying that because in my scenario a have a lot of columns. Maybe this is a trade-off?

Thank you,

Rodrigo

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster July 7, 2020

Hello, Rodrigo,
 
Thank you for your feedback.
 
You are right about the fact that all columns from the data set need to be mentioned in the mapping in order to be read by the component.
 
Even so, it is not mandatory to specify their data type or any other available property. It is enough to mention the unique name of the specific hierarchy to make it appear on the grid.
 
Please see the following code snippet for the reference:

mapping: {
dateTest: {}
}

 
Also, we have modified an example provided earlier so that it demonstrates the mentioned approach.
 
We hope it works for you.
Do not hesitate to contact us in case of further questions.
 
Regards,
Illia

Please login or Register to Submit Answer