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. Image for the cookie policy date

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

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


9 Replies

MP Manivannan Padmanaban Syncfusion Team 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.



MF Mahyar FF 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


MF Mahyar FF 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


VN Vignesh Natarajan Syncfusion Team 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. 
 



MF Mahyar FF 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


MF Mahyar FF 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


VN Vignesh Natarajan Syncfusion Team 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 





ZO zouzou August 19, 2019 08:34 AM UTC

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


MP Manivannan Padmanaban Syncfusion Team 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. 


Loader.
Live Chat Icon For mobile
Up arrow icon