Unplanned
Last Updated: 25 May 2020 13:31 by ADMIN
Toni
Created on: 25 May 2020 11:44
Category: DateInput
Type: Bug Report
1
DatePicker loses focus when used as data editor in the Grid and the input date starts with 0
DatePicker loses focus when used as data editor in the Grid and the input date starts with 0, for example 05/05/2020. As attached file, you can see a screen recording of the issue.
Attached Files:
1 comment
ADMIN
Svetoslav Dimitrov
Posted on: 25 May 2020 13:31

Hello,

As a workaround, for the time being you can put the DatePicker in an EditorTemplate (more information on EditorTemplate here: https://docs.telerik.com/blazor-ui/components/grid/templates#edit-template).

<TelerikGrid Data="@Data"
             Height="400px"
             Pageable="true"
             EditMode="@GridEditMode.Inline"
             OnUpdate="@UpdateHandler"
             Navigable="true">
    <GridColumns>
        <GridColumn Field="@nameof(MyDataModel.Id)" Title="Id" />
        <GridColumn Field="@nameof(MyDataModel.Name)" Title="Name" />
        <GridColumn Field="@nameof(MyDataModel.DateOfBirth)" Title="DOB" Width="150px">
            <EditorTemplate>
                @{
                    var item = context as MyDataModel;
                    <TelerikDatePicker @bind-Value="@item.DateOfBirth"></TelerikDatePicker>
                }
            </EditorTemplate>
        </GridColumn>
        <GridCommandColumn>
            <GridCommandButton Command="Edit" Icon="edit">Edit</GridCommandButton>
            <GridCommandButton Command="Save" Icon="save" ShowInEdit="true">Save</GridCommandButton>
            <GridCommandButton Command="Cancel" Icon="cancel" ShowInEdit="true">Cancel</GridCommandButton>
        </GridCommandColumn>
    </GridColumns>
</TelerikGrid>

@code {
    public void UpdateHandler(GridCommandEventArgs e)
    {
        var item = e.Item as MyDataModel;

        var index = Data.FindIndex(x => x.Id == item.Id);
        if (index != -1)
        {
            Data[index] = item;
        }
    }

    public List<MyDataModel> Data { get; set; } = Enumerable.Range(1, 20).Select(x => new MyDataModel()
    {
        Id = x,
        Name = $"Name {x}",
        DateOfBirth = DateTime.Today.AddDays(-x).Date
    }).ToList();

    public class MyDataModel
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public DateTime DateOfBirth { get; set; }
    }
}

Regards,
Svetoslav Dimitrov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.