Error GridEdit DateTime and Time

Hi,

   saving Datetime / Time data in a grid I came across 2 errors:

1. When saving a date and time with EditMode.Dialog and the provided form, 4 hours are added - even if you do not change the date value. (see attached video and DataGrid sample)

2. Creating a custom edit dialog with a TimePicker (which is the control I actually have to use) the edit window is not closed when saving and the OnActionComplete event is not reached.
In another  programm I noticed, that the changed DateTime data is not updated in OnActionComplete in the data property with the TimePicker control.The DateTimePicker updates the data, but adds 4 hours.

I am working with a german win 10 prof in Server Side Blazor with 18.1.0.55

   Maybe you can take a look.

        regards

            Uwe

Attachment: SyncError_76a761f9.zip

3 Replies 1 reply marked as answer

VN Vignesh Natarajan Syncfusion Team June 8, 2020 06:40 AM UTC

Hi Uwe,  
 
Thanks for contacting Syncfusion support.  
 
Query1: “When saving a date and time with EditMode.Dialog and the provided form, 4 hours are added 
 
We have validated your query and since it is a known issue, we have confirmed this as a defect Timezone issue occurs while updating datetime column in grid blazor componentand logged a defect report for the same. 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 2020 Volume 2 Main Release which is expected to be rolled out in the month end of June 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.  
 
 
Till then as a workaround, we suggest you to add the time difference the in OnActionBegin event of Grid while saving the changes. Refer the below code example. 
 
  <SfGrid ID="Grid" 
            DataSource="@Orders" 
. . . .  
            Toolbar="@(new List<string>() { "Add""Edit""Delete""Cancel""Update","ExcelExport"})" Height="315" Width="900"> 
  
        <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Dialog"></GridEditSettings> 
        <GridEvents OnActionBegin="Begin" TValue=Order></GridEvents> 
. . . . . . 
    </SfGrid> 
</div> 
<br /> 
@code 
{ 
    public List<Order> Orders { getset; } 
    SfGrid<Order> Grid; 
    public void Begin(ActionEventArgs<Order> Args) 
    { 
        if (Args.RequestType == Syncfusion.Blazor.Grids.Action.Save) 
        {  
            // remove the time difference from original while saving the changes. 
            Args.Data.OrderDate = Args.Data.OrderDate.Value.AddHours(-6); // give the value based on yours  
        } 
    } 
 
 
Query2: “the edit window is not closed when saving and the OnActionComplete event is not reached. 
 
We have analyzed the reported issue and found that you have enabled ColumnValidation in OrderID and CustomerID column. But you have not defined the controls in Template. Hence the reported issue occur while saving the changes. So kindly ensure to add the controls in Dialog Template that are defined in GridColumns with validation, if you want to perform validation in Grid Column. Kindly use style (display – none or visibility - hidden) to hide the section from Dialog Template.  
 
Refer the below code example  
 
<GridEditSettings AllowAdding="false" AllowEditing="true" AllowDeleting="false" Mode="EditMode.Dialog">           <Template>               @{                   var rowData = (context as Order1);                    <div style="visibility:hidden">                       <SfTextBox ID="OrderID" Value="@(rowData.OrderID.ToString())" Enabled="false"></SfTextBox>                       <SfTextBox ID="CustomerID" Value="@(rowData.CustomerID)"></SfTextBox>                   </div>                   <div class="form-group col-md-12">                       <SfTimePicker ID="OrderDate"                                     TValue="DateTime?"                                     Value="@(rowData.OrderDate)"                                     Format="HH:mm">                       </SfTimePicker>                   </div>               }           </Template>
 
<GridColumns>           <GridColumn Field=@nameof(Order1.OrderID) HeaderText="Order ID" IsPrimaryKey="true" ValidationRules="@(new { required=true})" TextAlign="TextAlign.Right" Width="120"></GridColumn>           <GridColumn Field=@nameof(Order1.CustomerID) HeaderText="Customer Name" ValidationRules="@(new { required=true})" Width="120"></GridColumn>           <GridColumn Field=@nameof(Order1.OrderDate) HeaderText=" Order Date" TextAlign="TextAlign.Right" Width="130" EditType="EditType.DateTimePickerEdit"></GridColumn>           <GridColumn Field=@nameof(Order1.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" EditType="EditType.NumericEdit" Width="120"></GridColumn>           <GridColumn Field=@nameof(Order1.ShipCountry) HeaderText="Ship Country" EditType="EditType.DropDownEdit" Width="150"></GridColumn></GridColumns>
 
 
 
Kindly get back to us if you have further queries. 
 
Regards, 
Vignesh Natarajan 


Marked as answer

UH Uwe Hein June 8, 2020 08:45 AM UTC

Hi Vignesh,

   thank you for the really fast response - your workaround cures the problem for now. 

Two last Questions:

1. What is the correct event to call when saving in Grid ? 

I always thought it was OnActionComplete, but you suggested OnActionBegin.

2. What is the correct event to call when saving in Scheduler ? 

OnActionBegin or ActionCompleted

    Thanks again

        regards

            Uwe



VN Vignesh Natarajan Syncfusion Team June 9, 2020 10:19 AM UTC

 
Thanks for the update.  
 
Query: “What is the correct event to call when saving in Grid ? I always thought it was OnActionComplete, but you suggested OnActionBegin. 
 
OnActionBegin event will be triggered when certain action is initiated and OnActionComplete event will triggered when certain action is completed. So to save / reflect the changes in Grid, we need to change the values in OnActionBegin event. We suggest you to achieve your requirement (to change the date object value) using OnActionBegin event of Grid when RequestType as Save. 
 
 
Query: “What is the correct event to call when saving in Scheduler ?  
 
We suggest you to use Scheduler ActionCompleted event which is appropriate event to save events in Scheduler. Refer the below documentation link for that.  
 
 
Please get back to us if you have further queries.  
 
Regards, 
Vignesh Natarajan 


Loader.
Up arrow icon