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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to completely disable datetime timezone correction in Grid?

Thread ID:

Created:

Updated:

Platform:

Replies:

144957 May 30,2019 10:04 AM UTC Jun 4,2019 10:53 AM UTC ASP.NET Core 1
loading
Tags: Grid
Gabor Horovitz
Asked On May 30, 2019 10:04 AM UTC

I am using UrlAdaptor, so all data transferred in JSON, so I can control how the JSON datetime serialized handle datetime

The server send the dates in UTC for example: DateTimeData=2020-06-01T04:00:00Z, 
The ej.data.DataUtil.serverTimezoneOffset is not touched (it is null). 

The grid renders datetime according to the browser's timezone setting.
I would like the grid do not touch the datetimes at all, I would like to display them in UTC (or untouched) regardless of any browser timezone





Farveen Sulthana Thameeztheen Basha [Syncfusion]
Replied On June 4, 2019 10:53 AM UTC

Hi Gabor, 

Thanks for contacting Syncfusion Support. 

Query#:- I would like the grid do not touch the datetimes at all, I would like to display them in UTC (or untouched) regardless of any browser timezone 
 
We have achieved your requirement “display date in UTC format without any browser timeZone” using CustomAdaptor by extending the UrlAdaptor on load event  and convert the date value to UTC before binding value into the Grid in the processResponse method. 
 
Please refer to the code example:- 
 
<ej-grid id="FlatGrid" allow-paging="true" load="load"> 
       <e-datamanager url="/Home/DataSource" adaptor="UrlAdaptor"></e-datamanager> 
     <e-columns> 
        <e-column field="OrderID" header-text="Order ID" text-align="Right" is-primary-key="true"></e-column> 
               .   .    . 
    </e-columns> 
</ej-grid> 
<script> 
    function load(args) { 
              this.model.dataSource.adaptor = new customadaptor(); 
      } 
 
    var customadaptor = new ej.UrlAdaptor().extend({ 
        processResponse: function (data, ds, query, xhr, request, changes) { 
 
             var res = JSON.parse(xhr.responseText); 
             for (var i = 0; i < res.result.length; i++) { 
                var date = res.result[i].Date.split("(")[1].split(")")[0];  // use your date column field name 
                value = new Date(parseInt(date)).toUTCString() 
                data.result[i].Date = value; 
                
            } 
            return this.base.processResponse.apply(this, [data, ds, query, xhr, request, changes]); 
        } 
    }); 
 
</script> 
 
Please get back to us if you need any further assistance. 

Regards, 
Farveen sulthana T 


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

Live Chat Icon For mobile
Live Chat Icon