Won't Fix
Last Updated: 22 Jun 2021 07:01 by ADMIN
Wei
Created on: 21 Jun 2021 14:02
Category: Grid
Type: Bug Report
1
Focus is lost when editing a cell and the next cell to be edited is not editable

Description

When the Grid/TreeList is in incell edit mode and you finish editing a cell by pressing "Enter", the focus is lost if the next cell to be edited is not editable.

Reproduction (if bug)

Steps to reproduce:

  1. Use the code

@using System.ComponentModel.DataAnnotations;

<TelerikGrid Data="@forecasts"
             Height="550px"
             FilterMode="@GridFilterMode.FilterMenu"
             Sortable="true"
             Pageable="true"
             PageSize="20"
             Groupable="true" Resizable="true"
             Reorderable="true"
             EditMode="@GridEditMode.Incell">
    <GridColumns>
        <GridColumn Field="Id" Title="Id" Width="100px" Editable="false" Groupable="false" />
        <GridColumn Field="Summary" Id="summary" Title="telerik bind-Value">
            <Template>
                @{
                    var model = context as WeatherForecast;
                    <span>@model.Summary</span>
                }
            </Template>
            <EditorTemplate>
                @{
                    var model = context as WeatherForecast;
                    if (model.CanEdit)
                    {
                        <TelerikTextBox @bind-Value="@model.Summary"></TelerikTextBox>
                    }
                    else
                    {
                        @model.Summary
                    }

                }
            </EditorTemplate>

        </GridColumn>

    </GridColumns>
</TelerikGrid>

@code {
    List<WeatherForecast> forecasts { get; set; }

    protected override void OnInitialized()
    {
        forecasts = WeatherForecast.GetForecastList();
    }

    public class WeatherForecast
    {
        public int Id { get; set; }

        public string Summary { get; set; }

        public bool CanEdit { get; set; }


        static public List<WeatherForecast> GetForecastList()
        {
            var rng = new Random();
            return Enumerable.Range(1, 150).Select(index => new WeatherForecast
            {
                Id = index,
                Summary = Summaries[rng.Next(Summaries.Length)],
                CanEdit = index % 3 != 0

            }).ToList();

        }

        private static readonly string[] Summaries = new[]
        {
            "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
        };
    }
}

  1. Click on the second column of row 1.
  2. After the cell editor is opened, press "Enter"

Current (if bug)

The focus is lost

Expected (if bug)

The focus should not be lost

Browser (if bug)

All

Project type (if bug)

All

Broken Telerik UI for Blazor version (if bug)

x.y.z

Last working version of Telerik UI for Blazor (if regression)

x.y.z

1 comment
ADMIN
Stamo Gochev
Posted on: 22 Jun 2021 06:23

Hello,

After a discussion with the dev team about the potential improvements, we agreed on the following:

1. Using an EditorTemplate implies (and requires) that an editor is expected to be present at all times during editing - displaying plain text only is not supported as this contradicts the idea of the grid entering edit mode, without any editor being present at all.
2.  If a certain cell should not be editable, use an editor that prevents editing, but is still focusable, e.g. one of the ways to achieve this is to use a read-only input. This results in better UX compared to the alternatives we considered as the end-user will be able to understand that the input is not editable, but can still interact with it.

The above being said, the EditorTemplate can be changed to the following:

<EditorTemplate>
	@{
		var model = context as WeatherForecast;

		if (model.CanEdit)
		{
			<TelerikTextBox @bind-Value="@model.Summary"></TelerikTextBox> }
		else
		{
			<input type="text"
					class="k-input k-readonly"
					value="@model.Summary" readonly />
		}
	 }
</EditorTemplate>

The idea can be improved depending on the project requirements, e.g. another editor can be used, the styling can be customized, etc.

Regards,
Stamo Gochev
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.