DateTime Column Editing. When Edit Completes It Returns Wrong Time

Hi
I copied an example from your documentation for DataGrid.
 I added a DateTime column to the grid. On completing  an edit on the DateTime column the
time is 2 hours later than shown? I can't understand why?


@page "/"

@using Syncfusion.Blazor.Buttons
@using Syncfusion.Blazor.DropDowns
@using Syncfusion.Blazor.Grids
@using Syncfusion.Blazor.Inputs

<SfGrid DataSource="@OrderData" Toolbar=@ToolbarItems>
    <GridEditSettings AllowEditing="true" AllowAdding="true" AllowDeleting="true"></GridEditSettings>
    <GridEvents TValue="Order" OnActionComplete="@ActionCompleteHandler"></GridEvents>
    <GridColumns>
        <GridColumn Field=@nameof(Order.Shipdate) HeaderText="Ship" Type="ColumnType.DateTime" EditType="EditType.DateTimePickerEdit" TextAlign="TextAlign.Center" Width="120"></GridColumn>
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="TextAlign.Center" Width="120"></GridColumn>
        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer ID" TextAlign="TextAlign.Center" Width="130"></GridColumn>
        <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" EditType="EditType.NumericEdit" Edit="@FreightEditParams" TextAlign="TextAlign.Center" Width="130"></GridColumn>
        <GridColumn Field=@nameof(Order.ShipName) HeaderText="Ship Name" TextAlign="TextAlign.Center" EditType="EditType.DropDownEdit" Edit="@ShipNameEditParams" Width="120"></GridColumn>
        <GridColumn Field=@nameof(Order.Verified) HeaderText="Verified" EditType="EditType.BooleanEdit" TextAlign="TextAlign.Center" DisplayAsCheckBox="true" Width="120" Edit="@VerifiedEditParams"></GridColumn>
    </GridColumns>
</SfGrid>

@code{


    public void ActionCompleteHandler(ActionEventArgs<Order> args)
    {
        if (args.RequestType == Syncfusion.Blazor.Grids.Action.Save)
        {

        }
    }









    public string[] ToolbarItems = new string[] { "Add", "Edit", "Delete", "Update", "Cancel" };

    public object FreightEditParams = new
    {
@@params = new SfNumericTextBox<int>() { Decimals = 3, Value = 4 }
};






public object VerifiedEditParams = new
{
@@params = new SfCheckBox() { Checked = true }
};

public object ShipNameEditParams = new
{
@@params = new SfDropDownList<string, Order>() { Value = "Hanari Carnes" }
};




List<Order> OrderData = new List<Order>
{
        new Order() { Shipdate= DateTime.Now, OrderID = 10248, CustomerID = "VINET", Freight = 32.38, ShipName = "Vins et alcools Chevalier", Verified = true },
        new Order() { Shipdate= DateTime.Now,OrderID = 10249, CustomerID = "TOMSP", Freight = 11.61, ShipName = "Toms Spezialitäten", Verified = false },
        new Order() { Shipdate= DateTime.Now,OrderID = 10250, CustomerID = "HANAR", Freight = 65.83, ShipName = "Hanari Carnes", Verified = true },
        new Order() {Shipdate= DateTime.Now, OrderID = 10251, CustomerID = "VICTE", Freight = 41.34, ShipName = "Victuailles en stock", Verified = false },
        new Order() { Shipdate= DateTime.Now,OrderID = 10252, CustomerID = "SUPRD", Freight = 51.3, ShipName = "Suprêmes délices", Verified = false },
        new Order() { Shipdate= DateTime.Now,OrderID = 10253, CustomerID = "HANAR", Freight = 58.17, ShipName = "Hanari Carnes", Verified = false },
        new Order() { Shipdate= DateTime.Now,OrderID = 10254, CustomerID = "CHOPS", Freight = 22.98, ShipName = "Chop-suey Chinese", Verified = true },
        new Order() { Shipdate= DateTime.Now,OrderID = 10255, CustomerID = "RICSU", Freight = 148.33, ShipName = "Richter Supermarket", Verified = true },
        new Order() { Shipdate= DateTime.Now,OrderID = 10256, CustomerID = "WELLI", Freight = 13.97, ShipName = "Wellington Importadora", Verified = false },
        new Order() { Shipdate= DateTime.Now,OrderID = 10257, CustomerID = "HILAA", Freight = 81.91, ShipName = "HILARION-Abastos", Verified = true }
    };

public class Order
{
    public DateTime? Shipdate { get; set; }
    public int OrderID { get; set; }
    public string CustomerID { get; set; }
    public double Freight { get; set; }
    public string ShipName { get; set; }
    public bool Verified { get; set; }
}
}


1 Reply 1 reply marked as answer

KM Kuralarasan Muthusamy Syncfusion Team July 6, 2020 01:14 PM UTC

Hi Paul, 
 
Thanks for contacting Syncfusion support. 
 
We suspect that the problem might have occurred because of the timezone settings in your machine. We have already confirmed this as a defect and logged a defect report for the same. Thank you for taking the time to report this issue “Timezone issue occurs while updating datetime column in grid blazor component” and helping us improve our product. At Syncfusion, we are committed to fixing all validated defects (subject to technological feasibility and Product Development Life Cycle ) and including the defect fix in our upcoming Vol2, 2020 release which is expected to be rolled out in mid of July 2020.   
  
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.   
 
Until then we suggest you to use the below way to overcome the problem you are facing. In the below code, we have bind the OnActionBegin event to Grid and in that event handler we will be updating the values of the date columns based on the delay(please add your delay hours as AddHours(2) or AddHours(-2) based on your scenario) to overcome the problem you are facing.  
 
  
<GridEvents OnActionBegin="OnActionBegin" TValue="Order"></GridEvents>  
  
  
    public void OnActionBegin(ActionEventArgs<Order> args)  
    {  
        if(args.RequestType.ToString() == "Save")             //based on your delay please set the value.   
        {  
            args.Data.StartTime = args.Data.StartTime.Value.AddHours(1);   //Based on your delay(-4 or -5 or +4 or +5 ) add the hours like AddHours(5) or AddHours(-5)  
        }  
    }  
  
 
Regards, 
Kuralarasan M 


Marked as answer
Loader.
Up arrow icon