This is a migrated thread and some comments may be shown as answers.

Groupby and rowchanged event

1 Answer 162 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Claude
Top achievements
Rank 1
Iron
Veteran
Claude asked on 20 Dec 2020, 01:05 AM

I have a grid with 5 columns.  If I drag a c column (say 4) to the group by box then the groups are shown.  If I try to expand the groupby box with the mouse, rowchanged event is triggered and then reading a value from a cell, I get a null exception error.  

Once the group is expanded, and I click on a row, I need the row changed event to trigger.  

 

also, can I show the number of items in each group.  Now it shows the group Text, but I want to show the group text and count in the group.

 

Thanks as always

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 21 Dec 2020, 12:26 PM

Hello, Claude,   

I would like to note that RadGridView offers the GroupExpanded event. It is fired when a group row is being expanded. However, you should know that the group rows (GridViewGroupRowInfo) doesn't store cells' values. That is why you probably experience the error when you try to access a cell's value from a group row. The data rows (GridViewDataRowInfo) actually have cells with associated values.  
        private void radGridView1_CurrentRowChanged(object sender, CurrentRowChangedEventArgs e)
        {
            if (e.CurrentRow!=null && (! (e.CurrentRow is GridViewGroupRowInfo)) && e.CurrentRow is GridViewDataRowInfo)
            {
                Console.WriteLine(e.CurrentRow.Cells["ProductName"].Value );
            }
        }
You can add a Count aggregate to the GroupDescriptor in order to show how many records have within the group:
https://docs.telerik.com/devtools/winforms/controls/gridview/grouping/group-aggregates 

The GroupSummaryEvaluate event allows you to customize the text displayed in the group row and show the number of rows that meet certain criteria. Please refer to the following help article demonstrating a sample approach: https://docs.telerik.com/devtools/winforms/controls/gridview/grouping/formatting-group-header-row 
 
I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
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/.

Tags
GridView
Asked by
Claude
Top achievements
Rank 1
Iron
Veteran
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or