Rowcount with filtered and/or grouped columns

Hi everybody,

  we are thinking of replacing a gridcontrol we use in older applications with a syncfusion control as we want to move to dotnet 6.

To display filtered / grouped or all rows rows, there are properties called FilteredInRowCount and  FilteredInNonGroupByRowCount (see attached video)

Snippet
string cText = this.cGridTitle + "   ->  " + this.uGrid_Auswahl.Rows.FilteredInRowCount.ToString() + " Rows " +														  " of " + this.uGrid_Auswahl.Rows.FilteredInNonGroupByRowCount.ToString() ;

Is there anything similar in sfDataGrid. I tried a sample based on sfGrid_DrawCell, but I failed because draw_cell was called more than once per row.

Snippet
	private void SfGrid_DrawCell(object sender, Syncfusion.WinForms.DataGrid.Events.DrawCellEventArgs e)
        {
            if (e.DataRow.RowType == RowType.CaptionCoveredRow && !string.IsNullOrEmpty(e.DisplayText)) 
            { 
                System.Diagnostics.Debug.WriteLine("SfGrid_DrawCell ++++++++++++++++++++++++++++++++++++");
                
                var group = (e.DataRow.RowData as Syncfusion.Data.Group); 
 
                if (group.Groups is null)
                { 
                    GroupCount++;
                    this.lbl_Caption.Text = GroupCount.ToString() + " von " + cAllRows;
                }
 
            }  

Thank you

   regards

       Uwe


Attachment: InfraGrid_9a2d838.zip

9 Replies

SS Sampathnarayanan Sankaralingam Syncfusion Team March 7, 2022 03:35 PM UTC

  
Hi Uwe, 
 
We suspect that you are looking for the possible way to get the rowcount after perform Filtering and group count after Grouping in SfDataGrid. You can get the RowCount of the DataGrid after Filtering and group count after Grouping using the SfDataGrid.View.Records.Count() and SfDataGrid.View.TopLevelGroup.Count(). Please find the code snippet below. 
 
 
//To get the filtered rowcount. 
this.sfDataGrid1.View.Records.Count(); 
 
//To get the group count after the column is grouped. 
this.sfDataGrid1.View.TopLevelGroup.Count() 
 
 
 
 
Please revert to us with more details if we have misunderstood your requirement. 
 
Regards, 
Sampath Narayanan.S 



UH Uwe Hein March 7, 2022 09:12 PM UTC

Hi  Sampath Narayanan.S,

   thank you for your answer. Could you please tell me what event to check after a column has been dropped onto the drop area to create a group in order to update my grid header. I tried ColumnDescriptions_CollectionChanged, but  sfDataGrid1.View.TopLevelGroup is null when this event is called.

  Thank you 

    regards

        Uwe

     



SS Sampathnarayanan Sankaralingam Syncfusion Team March 8, 2022 12:14 PM UTC

Hi Uwe,  
 
We have checked the requirement to get the count of the Row when column is dropped on the GroupDropArea as shown in the below code snippet. It can be get by using SfDataGrid.GroupColumnDescription.CollectionChanged event as shown below.  
 
this.sfDataGrid1.GroupColumnDescriptions.CollectionChanged += GroupColumnDescriptions_CollectionChanged; 
 
private void GroupColumnDescriptions_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) 
{ 
    MessageBox.Show(this.sfDataGrid1.View.TopLevelGroup.Count().ToString()); 
} 
 
 
Please refer the sample and let us know if you have any concerns. 
 
Regards, 
Sampath Narayanan.S 



UH Uwe Hein replied to Sampathnarayanan Sankaralingam March 8, 2022 07:58 PM UTC

Hi  Sampath Narayanan.S,

  

   thank you for your sample. There must be an error in TopLevelGroupCount. If you group on Role ID you get 7 for TopLevelGroupCount though there are only 2 different RowIds. 

So it should be 2 instead of 7!

  regards

     Uwe



SS Sampathnarayanan Sankaralingam Syncfusion Team March 9, 2022 02:36 PM UTC

Hi Uwe,  
 
Sorry for inconvenience, 
 
You can get the count of the grouped rows as shown in the below code snippet.  
 
 
this.sfDataGrid1.View.TopLevelGroup.Groups.Count() 
 
 
 
Please let us know if you have any concerns. 
 
Regards, 
Sampath Narayanan.S 



UH Uwe Hein replied to Sampathnarayanan Sankaralingam March 9, 2022 09:28 PM UTC

Hi,

   did you check your own sample ? 

this.sfDataGrid1.View.TopLevelGroup.Groups.Count()  returns the WRONG count. It must be 2 instead of 7. Please check your own sample ! 


Attachment: Sample849262872_(1)_6699a63f.zip


SS Sampathnarayanan Sankaralingam Syncfusion Team March 10, 2022 07:48 PM UTC

HI Uwe,


As we updated previously, if you need row count after Grouping you can get using `SfDataGrid.View.TopLevelGroup.Count()` and if you need the count of groupedrows, you can get using `SfDataGrid1.View.TopLevelGroup.Groups.Count()`.


Sample Link : https://www.syncfusion.com/downloads/support/forum/173387/ze/SfDataGridDemo333359215


Video Link : https://www.syncfusion.com/downloads/support/forum/173387/ze/Video-837015914



Please refer the sample and video from the link and let us know if you have any concerns.


Regards,

Sampath Narayanan.S



UH Uwe Hein replied to Sampathnarayanan Sankaralingam March 10, 2022 10:41 PM UTC

Hi  Sampath Narayanan.S,

  I must apologize - your answer was correct. I did not read carefully. Sorry...

    regards

         Uwe



SS Sampathnarayanan Sankaralingam Syncfusion Team March 11, 2022 04:57 PM UTC

Hi Uwe,


We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you. 


Regards,

Sampath Narayanan.S


Loader.
Up arrow icon