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

Datepickeredit value in datagrid not correct

Thread ID:

Created:

Updated:

Platform:

Replies:

144988 May 31,2019 08:02 AM UTC Jun 11,2019 02:16 PM UTC ASP.NET Core - EJ 2 5
loading
Tags: DataGrid
Mohd Mohaimin Zakaria
Asked On May 31, 2019 08:02 AM UTC

Hi,

I have a "datepickeredit" in datagrid.
But when the value is passed to the database, the value is minus 8 hours.
Is it because of timezone on the PC ?

Thavasianand Sankaranarayanan [Syncfusion]
Replied On June 3, 2019 09:03 AM UTC

Hi Mohd, 

Greetings from Syncfusion support. 

By default, while using remote data it send(response) the date object in UTC format and it does not converted to local time zone so we request you to apply the serverTimezoneOffset as below to resolve the reported problem. 


<script> 
    ej.data.DataUtil.serverTimezoneOffset = (2 * (new Date().getTimezoneOffset() / 60));   //Set the servertimezoneoffset 
</script> 
 
<ejs-grid id="Grid" allowPaging="true" toolbar="@(new List<string>() {"Add", "Edit", "Update", "Delete" })"> 
    <e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true"></e-grid-editSettings> 
    <e-data-manager url="/Home/UrlDataSource" adaptor="UrlAdaptor" insertUrl="/Home/Insert" , updateUrl="/Home/Update" removeUrl="/Home/Remove"></e-data-manager> 
    <e-grid-columns> 
        <e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" textAlign="Right" width="100"></e-grid-column> 
        ... 
   </e-grid-columns> 
</ejs-grid> 

Please find the below sample for more information. 


Please get back to us if you need further assistance 
 
Regards, 
Thavasianand S. 


Mohd Mohaimin Zakaria
Replied On June 4, 2019 01:36 AM UTC

Hi,

The solution you give is solve in view for the datepickeredit.
But when the data is passed to the entity and save to database, the value is still minus 8 hours.

Same with your example. When I debug, the date still minus 8 hours.

        public IActionResult Update([FromBody]CRUDModel<Orders> value)
        {
            var data = order.Where(or => or.OrderID == value.Value.OrderID).FirstOrDefault();
            if(data != null)
            {
                data.OrderID = value.Value.OrderID;
                data.CustomerID = value.Value.CustomerID;
                data.EmployeeID = value.Value.EmployeeID;
                data.OrderDate = value.Value.OrderDate;
                data.ShipCity = value.Value.ShipCity;
                data.Freight = value.Value.Freight;
            }
            return Json(value.Value);
        }



Thavasianand Sankaranarayanan [Syncfusion]
Replied On June 4, 2019 06:37 AM UTC

Hi Mohd, 
 
Please use the below code example to modify the date column value while saving the data in server end.  
 
  
 
 
function actionBegin(args) {  
            if (args.requestType === 'save') {  
                var grid = (document.getElementsByClassName("e-grid")[0] as any).ej2_instances[0];  
                var cols = grid.columns;   
                for (var i = 0; i < cols.length; i++) {  
                    if (cols[i].type == "date") {  
                        var date = args.data[cols[i].field];  
                        args.data[cols[i].field] = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMilliseconds()));  
                    }  
                }   
            }  
        }  
     

Please get back to us if you need further assistance. 

Regards, 
Thavasianand S. 


Mohd Mohaimin Zakaria
Replied On June 11, 2019 12:44 AM UTC

Could you please include the above code in your sample.
I still have problem with the date using your solution.
Thank you.

Thavasianand Sankaranarayanan [Syncfusion]
Replied On June 11, 2019 02:16 PM UTC

Hi Mohd, 

As per your suggestion we have prepared a sample and it can be downloadable from the below location. 


Regards, 
Thavasianand S. 


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