Completed
Last Updated: 14 Nov 2024 09:27 by ADMIN
Release 7.0.0
Greg
Created on: 20 Nov 2023 14:14
Category: Form
Type: Bug Report
7
Autogenerated date picker with nullable DateOnly / TimeOnly value shows '1/1/2001' / '12:00 AM' instead of format like the standard TelerikDatePicker

My Nullable DateOnly field shows as 1/1/2001 - I would expect it to be a more sensible default. The problem applies to all autogenerated DatePickers (like the Grid's filter DatePicker and the Form). The same issue is applicable to the TimeOnly struct.

 

===ADMIN EDIT===

In the interim, as a viable workaround, you can utilize the FormItem Template and declare a TelerikDatePicker like this:

@using System.ComponentModel.DataAnnotations

<TelerikForm Model="@PersonModel">
    <FormValidation>
        <DataAnnotationsValidator></DataAnnotationsValidator>
    </FormValidation>
    <FormItems>
        <FormItem>
            <Template>
                <label for="country">Date of Birth:</label>
                <TelerikDatePicker @bind-Value="@PersonModel.DOB" Width="200px" />
            </Template>
        </FormItem>
    </FormItems>
</TelerikForm>

@code {
    private Person PersonModel { get; set; } = new Person() { DOB = null };

    public class Person
    {
        [Display(Name = "Date of Birth")]
        public DateOnly? DOB { get; set; }
    }
}

 

0 comments