I am having an issue where if I have virtualization and grouping, when I right-click a row to view the context menu, all of the previously collapsed rows expand.
To replicate: use code below, add grouping, collapse a few groups, and right click to view the context menu. The groups all expand and you can no longer see which row you were clicking on.
If I remove the virtualization but use grouping, this doesn't happen. If I use virtualization but no grouping, this doesn't happen. It only seems to happen when you combine the two. Is there any way I can use both grouping, virtualization, and the context menu?
I used the sample code from the page https://blazor.radzen.com/datagrid-virtualization with a few modifications from the context menu sample code.
Full code I used here:
@using RadzenBlazorDemos.Data
@using RadzenBlazorDemos.Models.Northwind
@using Microsoft.EntityFrameworkCore
@inject ContextMenuService ContextMenuService
@inherits DbContextPage
<RadzenDataGrid Data="@orderDetails" TItem="OrderDetail" AllowVirtualization="true" Style="height:400px"
AllowFiltering="true" AllowGrouping="true" FilterPopupRenderMode="PopupRenderMode.OnDemand" FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" LogicalFilterOperator="LogicalFilterOperator.Or"
AllowSorting="true" VirtualizationOverscanCount="35" CellContextMenu="@OnCellContextMenu">
<Columns>
<RadzenDataGridColumn TItem="OrderDetail" Property="OrderID" Title="OrderID" />
<RadzenDataGridColumn TItem="OrderDetail" Property="ProductID" Title="ProductID" />
<RadzenDataGridColumn TItem="OrderDetail" Property="UnitPrice" Title="Unit Price">
<Template Context="detail">
@String.Format(new System.Globalization.CultureInfo("en-US"), "{0:C}", detail.UnitPrice)
</Template>
</RadzenDataGridColumn>
<RadzenDataGridColumn TItem="OrderDetail" Property="Quantity" Title="Quantity" />
<RadzenDataGridColumn TItem="OrderDetail" Property="Discount" Title="Discount">
<Template Context="detail">
@String.Format("{0}%", detail.Discount * 100)
</Template>
</RadzenDataGridColumn>
</Columns>
</RadzenDataGrid>
<EventConsole @ref=@console />
@code {
IEnumerable<OrderDetail> orderDetails;
EventConsole console;
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
orderDetails = dbContext.OrderDetails;
}
public void OnCellContextMenu(DataGridCellMouseEventArgs<OrderDetail> args)
{
ContextMenuService.Open(args,
new List<ContextMenuItem> {
new ContextMenuItem(){ Text = "Context menu item 1", Value = 1, Icon = "home" },
new ContextMenuItem(){ Text = "Context menu item 2", Value = 2, Icon = "search" },
new ContextMenuItem(){ Text = "Context menu item 3", Value = 3, Icon = "info" },
},
(e) => {
console.Log("test");
}
);
}
}