Automatic json date transformation

Stimulsoft Reports.JS discussion
imaltont
Posts: 12
Joined: Thu Dec 10, 2020 1:08 pm

Automatic json date transformation

Post 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.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Automatic json date transformation

Post by HighAley »

Hello,

Please, try to set the next static option:

Code: Select all

Stimulsoft.Base.StiBaseOptions.JsonParseTypeAsString = true
Thank you.
imaltont
Posts: 12
Joined: Thu Dec 10, 2020 1:08 pm

Re: Automatic json date transformation

Post 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?
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Automatic json date transformation

Post 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.
imaltont
Posts: 12
Joined: Thu Dec 10, 2020 1:08 pm

Re: Automatic json date transformation

Post 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.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Automatic json date transformation

Post 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.
imaltont
Posts: 12
Joined: Thu Dec 10, 2020 1:08 pm

Re: Automatic json date transformation

Post 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.
Attachments
Localized to Norwegian, with text field set to date
Localized to Norwegian, with text field set to date
localized_and_date.png (6.59 KiB) Viewed 3334 times
Localized to Norwegian, with text field set to general
Localized to Norwegian, with text field set to general
raw_text_input.png (6.69 KiB) Viewed 3334 times
SimpleList.mrt
Localized and set to date report template
(21.44 KiB) Downloaded 136 times
Demo.json
First value displayed in report changed to a date
(1.61 MiB) Downloaded 147 times
Lech Kulikowski
Posts: 6238
Joined: Tue Mar 20, 2018 5:34 am

Re: Automatic json date transformation

Post by Lech Kulikowski »

Hello,

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

Thank you.
imaltont
Posts: 12
Joined: Thu Dec 10, 2020 1:08 pm

Re: Automatic json date transformation

Post by imaltont »

Hello,

Are there any updates on this issue?
Lech Kulikowski
Posts: 6238
Joined: Tue Mar 20, 2018 5:34 am

Re: Automatic json date transformation

Post by Lech Kulikowski »

Hello,

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

Thank you.
Post Reply