Multiple Level Grouping - Different Caption Summaries

I would appreciate if someone can share how to define different format caption summaries for each level of the grouping in a multiple level grouping. Thanks.


1 Reply

KK Karthikraja Kalaimani Syncfusion Team August 24, 2021 12:32 PM UTC

Hi Halil,  

Thank you for contacting Syncfusion support.

We have prepared for you requirement "to show different caption summaries with format". In that sample, we written custom caption summary cell renderer to change the text of caption summary based on the level of the group. For more details, please refer to the below code snippets and attached. 

Code snippets : 
 
  
....
dataGrid.CellRenderers.Remove("CaptionSummary");
            dataGrid.CellRenderers.Add("CaptionSummary", new GridCaptionSummaryCellRendererExt());
....

public class GridCaptionSummaryCellRendererExt : GridCaptionSummaryCellRenderer
 
    { 
        public GridCaptionSummaryCellRendererExt() 
        { 
        } 
  
        public override void OnInitializeDisplayView(DataColumnBase dataColumn, SfLabel view) 
        { 
            base.OnInitializeDisplayView(dataColumn, view); 
            view.HorizontalTextAlignment = TextAlignment.Center; 
            view.BackgroundColor = Color.DarkCyan; 
            view.FontSize = 16; 
            view.TextColor = Color.White; 
            Group group = dataColumn.RowData as Group; 
            string key = dataColumn.GridColumn.MappingName; 
            if (group != null && key != null) 
            { 
                if (view.Text.Contains("No_1")) 
                { 
                    //Count 
                    view.Text = view.Text; 
                } 
                else if (view.Text.Contains("No_2")) 
                { 
                    //Sum 
                    double? sum=0; 
  
                    foreach (var records in group.Groups[0].Records) 
                    { 
                        sum = sum + (records.Data as Data).No_2; 
                    } 
                    view.Text = "No_2 -" + sum; 
                } 
                else if (view.Text.Contains("No_3")) 
                { 
                    //Average 
                    double? sum = 0; 
                    foreach (var records in group.Records) 
                    { 
                        sum = sum + (records.Data as Data).No_3; 
                    } 
                    view.Text = "No_3 -" + (sum/group.GetSourceCount()); 
                } 
  
            } 
        } 
    } 


Loader.
Up arrow icon