Groupby and rowchanged event

2 posts, 0 answers
  1. Claude
    Claude avatar
    39 posts
    Member since:
    Jun 2020

    Posted 19 Dec 2020 Link to this post

    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

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4178 posts

    Posted 21 Dec 2020 Link to this post

    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/.

Back to Top