Completed
Last Updated: 26 Mar 2022 12:52 by ADMIN
Release 3.2.0
Tom
Created on: 14 Oct 2021 16:38
Category: Grid
Type: Bug Report
0
Selected row disappears when editing a Grid cell

GridCheckBoxColumn:  The check disappears when focus is on a editable cell.

    <TelerikGrid Class=k-grid 
                 Data="@adherenceAgents" 
                 EditMode="@GridEditMode.Incell"
                 Height="150px"
                 SelectionMode="@GridSelectionMode.Single">
                    
        <GridColumns>
            <GridCheckboxColumn SelectAll="false" Title="Select" Width="70px" />
            <GridColumn Field="@(nameof(AdherenceAgent.Scheduled))" Editable="false" Title="Scheduled" />
            <GridColumn Field="@(nameof(AdherenceAgent.EmployeeId))" Editable="false" Title="Employee ID" />
            <GridColumn Field="@(nameof(AdherenceAgent.Name))" Editable="false" Title="Name" />
            <GridColumn Field="@(nameof(AdherenceAgent.AchievedAdherences))" Title="Points" />
            <GridColumn Field="@(nameof(AdherenceAgent.PossibleAdherences))" Title="Possible" />
            <GridColumn>
                <HeaderTemplate>Adherence<br/>Score</HeaderTemplate>
            </GridColumn>
         </GridColumns>
    </TelerikGrid>

 

1 comment
ADMIN
Dimo
Posted on: 21 Oct 2021 13:14

Hi Tom,

The described behavior is caused by the fact that the edited row is a different object instance than the original selected row.

A possible workaround is to:

  • Enable multiple row selection
  • If you need single row selection, then simulate it with the SelectedItemsChanged event

In the meantime, I will ask our developers to confirm this is a bug and will follow-up.

<TelerikGrid Data="@GridData"
             EditMode="@GridEditMode.Incell"
             SelectedItems="@SelectedItems"
             SelectionMode="GridSelectionMode.Multiple"
             SelectedItemsChanged="@( (IEnumerable<Product> items) => SelectedItemsChanged(items) )">
    <GridColumns>
        <GridCheckboxColumn SelectAll="false" Title="Select" Width="70px" />
        <GridColumn Field=@nameof(Product.Name) Editable="false" Title="Product Name" />
        <GridColumn Field=@nameof(Product.Price) Title="Price" />
    </GridColumns>
</TelerikGrid>

@code {
    List<Product> GridData { get; set; }
    IEnumerable<Product> SelectedItems { get; set; } = new List<Product>();

    async Task SelectedItemsChanged(IEnumerable<Product> items)
    {
        if (items.Any())
        {
            SelectedItems = new List<Product>() { items.Last() };
        }
        else
        {
            SelectedItems = new List<Product>();
        }
    }

    protected override void OnInitialized()
    {
        GridData = new List<Product>();
        var rnd = new Random();

        for (int i = 1; i <= 5; i++)
        {

            GridData.Add(new Product()
            {
                ID = i,
                Name = "Product " + i.ToString(),
                Price = (decimal)rnd.Next(1, 100),
                Quantity = (short)rnd.Next(1, 100)
            });
        }
    }

    public class Product
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public decimal Price { get; set; }
        public short Quantity { get; set; }
    }
}

 

Regards,
Dimo
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.