Hide Empty Group

Hi,

I have a SFDataGrid which has a TextColumn and a GridComboBoxColumn. The data is grouped by the id of a Id/Value object whose content can be selected via the combobox column (2. Column).

Unbenannt.jpg


I want to show also the groups that are empty (like Group 2 and Group 4).

Is it possible to show only the group headers if a group is empty and not the row (Criteria: 1.Column is Null)? 


Thanks for your help!

Maria


3 Replies

LN Lakshmi Natarajan Syncfusion Team October 28, 2021 02:11 PM UTC

Hi Maria, 
 
Thank you for using Syncfusion products. 
 
We have checked the reported query “Hide Empty Group” from our side. We would like to inform you that you can customize the RowHeight by using SfDataGrid.QueryRowHeight event.  
 
Please refer to our user guidance document regarding the same, 
 
Please refer to the following code snippets to achieve your requirement, 
private void dataGrid_QueryRowHeight(object sender, QueryRowHeightEventArgs e) 
{ 
    var item = dataGrid.GetRecordAtRowIndex(e.RowIndex) as OrderInfo; 
    var isGrouped = dataGrid.GroupColumnDescriptions.Count > 0; 
             
    if (item != null && isGrouped && string.IsNullOrEmpty(item.FirstName)) 
    { 
        e.Height = 0; 
        e.Handled = true; 
    } 
} 
 
We have prepared a sample based on your requirement and attached in the following link, 
 
Output 
 
 
Please let us know if you need further assistance. 
 
Regards, 
Lakshmi Natarajan 
 



AN Andy November 4, 2021 09:17 AM UTC

Thank you! It works like charm!



SV Suja Venkatesan Syncfusion Team November 8, 2021 11:46 AM UTC

Hi Maria, 

Thanks for the update.  

We are glad to know that the provided solution worked at your end. Please let us know if you need any other assistance.   

Regards, 
Suja. 



Loader.
Up arrow icon