I want to show only non-empty columns in RadzenDataGrid, and adjust column visibility in accordance with applied filter. I achieve that by setting column's Visible property. Everything works fine except when clearing the column filter after some columns were hidden. When I click on "Clear" button inside the column filter popup, the popup doesn't get hidden and becomes "broken". It can't be closed in any way. Please see provided code example and screen recording for additional details.
<RadzenDataGrid @ref="_grid" Data="Items" AllowFiltering="true">
<Columns>
<RadzenDataGridColumn TItem="Item" Property="A" Title="A" Visible="@(IsColumnVisible("A"))" />
<RadzenDataGridColumn TItem="Item" Property="B" Title="B" Visible="@(IsColumnVisible("B"))" />
<RadzenDataGridColumn TItem="Item" Property="C" Title="C" Visible="@(IsColumnVisible("C"))" />
</Columns>
</RadzenDataGrid>
@code {
private RadzenDataGrid<Item> _grid;
public IEnumerable<Item> Items { get; set; } = new List<Item>
{
new Item { A = "A1", B = "", C = "C1" },
new Item { A = "A2", B = "B2", C = "C2" },
};
bool IsColumnVisible(string propertyName)
{
return !_grid.View.All(item => string.IsNullOrEmpty(item[propertyName]));
}
public class Item
{
public string A { get; set; }
public string B { get; set; }
public string C { get; set; }
public string this[string propertyName]
{
get
{
switch (propertyName)
{
case "A":
return A;
case "B":
return B;
case "C":
return C;
default:
throw new ArgumentOutOfRangeException();
}
}
}
}
}