Won't Fix
Last Updated: 04 Apr 2022 12:38 by ADMIN
Created on: 30 Mar 2022 07:42
Category: GridView
Type: Bug Report
Group property of GridViewGroupFooterRow is incorrect in Virtualizing scenarios


I am currently having issues with RadGridView's group footer: I am trying to add a button to the footer template which is supposed to trigger a command which in turn needs some info on the group it was triggered from*.

Since (unlike the header) there does not seem to be any info on the group available directly within the GroupFooterTemplate, I am pulling the group info from the parent GridViewGroupFooterRow:

                <telerik:GridViewDataColumn [...]>
                            <Button Command="{Binding DataContext.ShowFooterGroupCommand, RelativeSource={RelativeSource AncestorType=telerik:RadGridView}}"
                                    CommandParameter="{Binding Group.Key, RelativeSource={RelativeSource AncestorType=telerik:GridViewGroupFooterRow}}" />

This is working great as long as the RadGridView does not use Row virtualization. However, when I turn on Row virtualization and scroll around for a bit, the value I get passed as the CommandParameter is more or less random and has nothing to do with the group my button is actually located in.

I attached a small example project (.Net 6 but our app uses 4.8 so I set that as the Framework below) for you to try it yourself. Just scroll around and click the buttons while watching the debug output window. You will see that the groups in the output window will not match the group where you actually clicked the button after some scrolling.

Expected Behavior

Even when virtualizing, the Group key returned when binding to GridViewGroupFooterRow.Group(.Key) should reliably return the key of the actual group my button is placed in. It would be even better if it was somehow possible to get the group directly, without having to resort to FindAncestor.

Simon M├╝ller
Hofmann F├Ârdertechnik GmbH


* Basically I am trying to give the user a possibility to add new items to the individual groups and I don't want to add the button to the group header since that makes it too easy to accidentally hit the header's RadToggleButton, collapsing the group.

Attached Files:
1 comment
Dilyan Traykov
Posted on: 04 Apr 2022 12:38

Hi Simon,

Thank you for the provided project and code snippet.

The behavior you described is expected due to the UI Virtualization mechanism of the RadGridView and the way the binding for the CommandParameter is set up. In this case, it will not be reevaluated when the new cell is brought into view and since the containers are reused, the group of the reused cell will be returned. I want to clarify that this behavior stems from the WPF framework and not from the implementation of the mechanism.

To have this work as expected, you can programmatically assign the CommandParameter in the CellLoaded event of the RadGridView control like so:

        private void MyGridView_CellLoaded(object? sender, Telerik.Windows.Controls.GridView.CellEventArgs e)
            if (e.Cell is GridViewGroupFooterCell)
                var footerCell = e.Cell as GridViewGroupFooterCell;
                var footerRow = footerCell.ParentOfType<GridViewGroupFooterRow>();
                var button = footerCell.Content as Button;
                if (button != null)
                    button.CommandParameter = footerRow.Group;

I've also updated the sample project to demonstrate this. Please let me know whether such an approach would work for you.

Dilyan Traykov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Attached Files: