Need More Info
Last Updated: 17 Nov 2021 16:05 by ADMIN
Yovko
Created on: 23 Oct 2021 16:43
Category: UI for ASP.NET Core
Type: Bug Report
0
Bug when manually entering date inside a grid in cell edit mode

 

I have an editable kendo grid in which I have a date field. When I choose a date through the calendar for example: 26.12.2021 on post the model binder parses the date correctly.

If I manually enter the date in the cell the model binder parses the date as it was not an UTC and since my time zone is +2h it comes in the controller as 25.12.2021 22:00

(see the attached files)

 

Inside my startup.cs I have defined JsonOptions like this:

.AddNewtonsoftJson(options =>
                {
                    options.SerializerSettings.ContractResolver = new DefaultContractResolver();
                    options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
                });

 

In the Configure method:

var supportedCultures = new[] { new CultureInfo("bg-BG") };

app.UseRequestLocalization(new RequestLocalizationOptions
{
         DefaultRequestCulture = new RequestCulture("bg-BG"),
         SupportedCultures = supportedCultures,
         SupportedUICultures = supportedCultures
});

Layout.cshtml

<script src="~/lib/kendo/js/cultures/kendo.culture.bg-BG.min.js"></script>

<script>
        kendo.culture("bg-BG");
</script>

5 comments
ADMIN
Mihaela
Posted on: 17 Nov 2021 16:05

Hi Yovko,

Thank you for the provided video.

In order to investigate what is causing the behavior on your side, would you please share the following information:

  • The grid's configuration;
  • If the Date column has a custom editor template, please provide it;
  • Would you please explain how the updated dates are converted to UTC format in the Update request?

In addition, you could review the ParseFormats() method (client-side method: parseFormats) that specifies the format used to parse the DatePicker value in the following cases:

  • when the user inserts the date manually, without selecting a date from the DatePicker;
  • when the value/date is set programmatically in the Datepicker via the "value" method.

Hopefully, it would be helpful to resolve the issue.

Looking forward to your feedback.

Regards, Mihaela Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Yovko
Posted on: 11 Nov 2021 15:31
Sorry for the delayed response. Here's a quick video of the issue, I hope it'll be helpful for reproducing it.
Attached Files:
ADMIN
Mihaela
Posted on: 02 Nov 2021 09:38

Hi Yovko,

Thank you for your feedback.

I have updated the editor template of the DateTime field "OrderDate" to DatePicker, but I still cannot replicate the issue at my end. The correct manually entered date is received in the Controller: https://www.screencast.com/t/8lNDFSzcdu

The editor template is configured as follows:

 

//Model
public class OrderViewModel
{
        [UIHint("Date")]
        public DateTime? OrderDate { get; set; }
}

//Date.cshtml
@model DateTime?

@(Html.Kendo().DatePickerFor(m => m))

 

Attached is the revised runnable sample for your reference. It would be great to update it based on your code to replicate the issue and send it back in the thread. I will investigate the described behavior and share the respective suggestions.

Looking forward to your feedback.

 

Regards, Mihaela Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Attached Files:
Yovko
Posted on: 31 Oct 2021 08:31

Additional info: 

@Mihaela

I saw your video, but the difference of what I need to do is this: When entering values manually I enter only the date and not the time.

So in this case I need to enter for ex. 20.12.2021 and get the exactly the same date inside the controller.

ADMIN
Mihaela
Posted on: 29 Oct 2021 11:22

Hi Yovko,

Thank you for the provided screenshots and code snippets.

I have prepared a demo project to replicate the described issue. It appears that the correct Date value is added to the Update request (when selecting the Date from the calendar or entering it manually) at my end. Here is a screencast for your reference: https://www.screencast.com/t/0wv4lX4Jc

Also, I have noticed that the Date is sent in UTC format at your end. Would you please explain how it is converted to UTC format at your end?

In addition, feel free to modify the attached sample based on the behavior you are experiencing and send it back in the thread. I will test it locally and follow up on the Bug report.

Thank you for your cooperation!

 

Regards, Mihaela Progress Telerik

Remote troubleshooting is now easier with Telerik Fiddler Jam. Get the full context to end-users' issues in just three steps! Start your trial here - https://www.telerik.com/fiddler-jam.
Attached Files: