Completed
Last Updated: 01 Feb 2022 11:16 by ADMIN
Release 3.1.0
Vitro
Created on: 28 Jan 2022 10:15
Category: Grid
Type: Bug Report
2
Second Grid on the page clears first Grid SearchBox

If you create a second Grid on the page, it will clear the SearchBox input value of the first Grid.

<p><TelerikButton OnClick="@ToggleSecondGrid">Toggle Second Grid</TelerikButton></p>

<TelerikGrid Data="@GridData">
    <GridToolBar>
        <GridSearchBox />
    </GridToolBar>
    <GridColumns>
        <GridColumn Field=@nameof(Product.ProductName) Title="Product Name" />
    </GridColumns>
</TelerikGrid>

@if (ShowSecondGrid)
{
    <TelerikGrid Data="@( new List<Product>() )">
        <GridColumns>
            <GridColumn />
        </GridColumns>
    </TelerikGrid>
}

@code {
    List<Product> GridData { get; set; }

    bool ShowSecondGrid { get; set; }

    async Task ToggleSecondGrid()
    {
        ShowSecondGrid = !ShowSecondGrid;
    }

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

        for (int i = 1; i <= 5; i++)
        {
            GridData.Add(new Product()
            {
                ProductId = i,
                ProductName = "Product " + i.ToString(),
                UnitPrice = (decimal)(i * 3.14),
                UnitsInStock = (short)(i * 1),
                Discontinued = false
            });
        }
    }

    public class Product
    {
        public int ProductId { get; set; }
        public string ProductName { get; set; }
        public decimal? UnitPrice { get; set; }
        public short? UnitsInStock { get; set; }
        public bool Discontinued { get; set; }
    }
}

1 comment
ADMIN
Dimo
Posted on: 28 Jan 2022 10:31

Hello,

Thank you for reporting this bug. While we fix it, here are two possible workarounds:

  • Get and set Grid State after the Window shows. This will restore the SearchBox value, because the internal Grid state is correct - it's just the textbox value that is missing.
  • Render a fake invisible searchbox before the real SearchBox. In this way, the second Grid will not affect the real SearchBox during its initialization.

Regards,
Dimo
Progress Telerik

Learn about the important changes coming in UI for Blazor 3.0 in January 2022!