We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

date string in json object retrieved by urlAdaptor is being converted to date object

Thread ID:

Created:

Updated:

Platform:

Replies:

143059 Mar 2,2019 12:45 PM UTC Aug 20,2019 10:18 AM UTC ASP.NET MVC 9
loading
Tags: Grid
Mahyar FF
Asked On March 2, 2019 10:27 PM UTC

Hi
After version 16.3.0.21 ej-grid with UrlAdaptor datamanager automatically converts date string to date object before databinding and rendering.
thus the converted object date "Fri May 11 2018 02:00:00 GMT+0200 (Central European Summer Time)"  will be showed in grid column instead of string "2018-05-11" !

I had analysed the scripts and found out which there is a method called jsonReviver in ej.data.js which contains a code line with date pattern testing regex,
which in version 16.3.0.21 and before it will not match a string date, but after that version it will match.

here is the code for ej.data.js version 16.3.0.21:
     else if (/^(\d{4}\-\d\d\-\d\d([tT][\d:\.]*){1})([zZ]|([+\-])(\d\d):?(\d\d))?$/.test(value))
and for next versions is:
     else if (/^(\d{4}\-\d\d\-\d\d)|(\d{4}\-\d\d\-\d\d([tT][\d:\.]*){1})([zZ]|([+\-])(\d\d):?(\d\d))?$/.test(value))

I need to show exactly the string date as it has retrieved from json, so please fix this,
or define an option in grid or datamanager which bypasses this behaviour.

Thanks


Manivannan Padmanaban [Syncfusion]
Replied On March 4, 2019 03:46 PM UTC

Hi Mahyar, 

 

Thanks for contacting syncfusion support. We are happy to assist you.

 

Query: I need to show exactly the string date as it has retrieved from json

 

To achieve your requirement we suggest you to define the type as “date” in the column definition and also you can specific the desire format using format property. Refer the below code example,

 

@(Html.EJ().Grid<object>("testGrid")

           …………..

        .Columns(col =>

                {

                  

                    col.Field("OrderID").IsPrimaryKey(true).Add();

                    col.Field("OrderDate").HeaderText("OrderDate").Type("date").Format("{0:yyyy-MM-dd}").Add();

                })

)

 

 

Also refer the below link for help documentation,

https://help.syncfusion.com/aspnetmvc/grid/columns#type

https://help.syncfusion.com/aspnetmvc/grid/columns#format

 

Regards,

Manivannan Padmanaban.


Mahyar FF
Replied On March 5, 2019 09:14 AM UTC

Hi Manivannan

Thanks
it had worked completely.
but this is just a workaround, the data processing routine (in ej.data.js) should not change the data type retrieved from json, unless user asks so.
specially for string values.
the workaround you gave, is forcing me to alter 50 views in my project (or in other way alter 50 models).

Regards
Mahyar

Mahyar FF
Replied On March 6, 2019 11:02 AM UTC

Now i'm facing the same problem with EJ DropDownList.
I have a list containing date string values, which will be retrieved as json using UrlAdaptor.
all of data are converted to date objects and therefor a list of "undefined" will be returned!

1

2

3

Regards
Mahyar

Vignesh Natarajan [Syncfusion]
Replied On March 6, 2019 11:46 AM UTC

Hi Mahyar, 
 
Query: “the data processing routine (in ej.data.js) should not change the data type retrieved from json 
 
By default we will parse the date string to date Object before binding it to Grid or dropdownlist (i.e while serializing). But if you want to string to be as it is kindly disable the boolean (ej.dateParse) in your sample.  
 
<script> 
      ej.dateParse = false; 
</script> 
 
Since you want to apply the changes in the multiple view pages. We suggest you to refer the below script file (dateparse.js) after the ej.web.all js file reference.  
 
Please get the script file from the below location. 
 
 
Please remove the previous suggestion, when referring the above script file. 
 
Note: Using above solution will resolve the issue related to EJ1 Dropdownlist also.  
 
Please get back to us if you have further queries.  
 
Regards, 
Vignesh Natarajan. 
 


Mahyar FF
Replied On March 7, 2019 08:36 AM UTC

Hi Vignesh

Thanks for your help
it worked great.
as i had put the ej.dateParse = false in the Layout file
i hope changing it does not effect somewhere else in the code (for example where the date should be parsed as object) ;-)

Regards
Mahyar

Mahyar FF
Replied On March 7, 2019 01:09 PM UTC

Ok, it seems the effects of original problem still remains in other parts.
I also have a Grid which is loaded with local data (ej.isJSON) with some string columns containing string dates (like: 2019-03-07).
but the dates are being parsed and showed then.
changing ej.dateParse has no effect on this as it is local data.
the only way to make it working is to add "{0:yyyy-MM-dd}" Format option to the specified column in EJ().Grid, 
but here another problem comes up which is exporting to excel, which dates will be exported and showed as "2019-03-07T00:00:00.000Z
" which is not the result i want!
 
i'm not sure, maybe it's better to redefine "ej.parseJSON" method as it can be done without manipulating ej.data.js,
or you should consider placing ej.dateParse flag in p.parseJson method in future releases..

Regards
Mahyar

Vignesh Natarajan [Syncfusion]
Replied On March 8, 2019 10:46 AM UTC

Hi Mahyar, 

Sorry for the inconvenience caused. 
We have validate the defect you have initiated with us. Thank you for the taking the time to report the issue ad helpding us improve our product. At Syncfusion we are committed to fixing all the validated defect (subject to technological feasibility and Product Development Life Cycle) and inclusing the defect fix in out subsequent 2019 Volume 1 Service pack 1 release. You can track the current status of your request, review the resolution timeline and contact us for any further inquiries through this link 


Till then we appreciate your patience.  

Note: Above feedback link is in review stage and it will be visible to you once reviewed.  

Regards, 
Vignesh Natarajan 




zouzou
Replied On August 19, 2019 08:34 AM UTC

Hello i have the same problem when i try to access the link it says access denied.

Manivannan Padmanaban [Syncfusion]
Replied On August 20, 2019 10:18 AM UTC

Hi zouzou, 
 
Thanks for contacting Syncfusion Support.  
 
We have already fixed the reported issue. Kindly upgrade to minimum V17.1.0.47 to maximum V17.2.0.28 to avoid the reported issue. 
 
Please get back to us, if you need further assistance. 
 
Regards, 
Manivannan Padmanaban. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;