Page 1 of 2

Automatic json date transformation

Posted: Thu Dec 17, 2020 7:38 am
by imaltont
Hello.

Is it possible to turn of the automatic handling of dates in DataSet.readJson? Currently I want to read in dates in ISO 8601 and just let it be when reading them and later transform it inside stimulsoft, as this seems more reliable. Using datetime in the datasource-list inside stimulsoft is not an option as it seems to then have trouble with a list of dates where the first date is null. The template also needs to be compatible with the .NET version.

The way it creates problems atm is that instead of giving the report a date on the yyyy-MM-ddThh-mm-ssZ format like the data is saved as, it gives the report dd-MM-yyyy hh-mm-ss (local date format), but if I then try to use the date-formating options inside stimulsoft, it will flip the day and month when rendering if they are ambiguous e.g. 11.12.20 will be rendered as 12.11.20. This problem of flipped dates is also not present in Firefox, only in Chrome/Chromium-based browsers.

In the .NET version I could turn of date handling for the serializer (Newtonsoft) and handling the dates as just strings worked well, but I can't seem to find how/if it's possible with the readJson method for the JS reports.

Re: Automatic json date transformation

Posted: Fri Dec 18, 2020 10:44 am
by HighAley
Hello,

Please, try to set the next static option:

Code: Select all

Stimulsoft.Base.StiBaseOptions.JsonParseTypeAsString = true
Thank you.

Re: Automatic json date transformation

Posted: Mon Dec 21, 2020 10:13 am
by imaltont
Hello,

I get that Stimulsoft.Base.StiBaseOptions.JsonParseTypeAsString is undefined when I try to use this setting in the JS version. Stimulsoft.StiOptions.JsonParseTypeAsString = true does not give any errors, but no matter where I put it, it has no effect at all on the rendered report. I'm also having trouble finding any of this in the documentation. Where is/should I use this option?

Re: Automatic json date transformation

Posted: Tue Dec 22, 2020 7:12 am
by HighAley
Hello,

Sorry, maybe we didn't understand you right.
Could you send us a sample (you could use our samples on Github to create it) that will let us reproduce your issue?

Thank you.

Re: Automatic json date transformation

Posted: Tue Dec 22, 2020 2:20 pm
by imaltont
Hello,

Using this example, if you change one of the values displayed in the list in the Demo.json to a date (e.g. 2020-05-06T00:00:00Z) and render without doing anything to the template, the report renders it as some other format (for me in this example MM/dd/yyyy), I want it to be rendered as the un-edited ISO 8601 format I put into the json file when the textfield format type is General.

The problem shows itself more clearly if you also change the text field inside the report to show a date, and set the culture to nb-NO (Norwegian). This renders the example date as 05.06.2020, when it should have been 06.05.2020.

Re: Automatic json date transformation

Posted: Tue Dec 22, 2020 3:08 pm
by HighAley
Hello,

There are no date shown from the Data.json file.
Could you modify the sample and send it to us?

Could you also attach screenshots that will show the issue?

Thank you.

Re: Automatic json date transformation

Posted: Wed Dec 23, 2020 7:57 am
by imaltont
Hello,

I know there are no dates in it, that's why I said to change any of them to a date. I'll add attachements that can show the problem.

I'm adding the .mrt file with culture set to Norwegian and the text box with a date set to date format, what the report gets inputed as a raw string, what it renders in the text field type is set to date, and the edited .json file.

I want the raw string to come into stimulsoft the same way it is displayed in the Json file, as it seems to eliminate all problems with dates when stimulsoft itself can do the formatting rather than the serializer doing it before stimulsoft gets it, as it can then be ambiguous. In the .NET version I can do this by setting the DateParseHandling property to None, but I haven't managed to find any way of doing this in the JS version.

Re: Automatic json date transformation

Posted: Mon Dec 28, 2020 4:16 pm
by Lech Kulikowski
Hello,

We need some additional time to investigate the issue, we will let you know about the result.

Thank you.

Re: Automatic json date transformation

Posted: Wed Jan 13, 2021 8:31 am
by imaltont
Hello,

Are there any updates on this issue?

Re: Automatic json date transformation

Posted: Mon Jan 18, 2021 11:17 am
by Lech Kulikowski
Hello,

We are working on the problem. We will let you know when the solution is available.

Thank you.