We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Custom group header cells with column totals?

Thread ID:





129931 Apr 10,2017 09:09 PM UTC May 1,2017 11:29 AM UTC Xamarin.iOS 8
Tags: SfDataGrid
Clint Anderson
Asked On April 10, 2017 09:09 PM UTC

I have the data in my grid separated out into groups.  I see that from https://help.syncfusion.com/xamarin-ios/sfdatagrid/summary I can do some customization of the group header cells to include some descriptions and calculations from the data in that group.  

Is it possible to do something like this:

Bob Barker  --------------------- 2093223423223424...this could all float together$60$30$30
Code 1First$10$10$0
Code 2Second$30$10$20
Code 3Another$20$10$10

Where the first row is the header, the second row is a group header, and the remaining rows are part of that group. The issue I am questioning is if I can have the Paid, Incurred, and Reserves columns summed within my section header while still being able to display my section description that could float over multiple other columns

Clint Anderson
Replied On April 11, 2017 12:07 PM UTC

I also forgot to ask this before, is there any way to add arbitrary components into the section headers?  For example, after the name and identification
number, could I created 2 buttons before my totaled columns?

Sivaraman Sivagurunathan [Syncfusion]
Replied On April 11, 2017 06:03 PM UTC

Hi Clint Anderson,

Thanks for contacting Syncfusion support.

You can customize the caption summary row by setting the SfDataGrid.CaptionSummaryRow property. 

Refer the below code example in which we have customized the summary to display the data you wanted.


GridSummaryRow summaryRow = new GridSummaryRow(); 
summaryRow.ShowSummaryInRow = false; 
GridSummaryColumn summary = new GridSummaryColumn(); 
summary.Name = "Paid"; 
summary.MappingName = "Paid"; 
summary.Format = "{Sum:c}"; 
summary.SummaryType = SummaryType.DoubleAggregate; 
GridSummaryColumn summary1 = new GridSummaryColumn(); 
summary1.Name = "Incurred"; 
summary1.MappingName = "Incurred"; 
summary1.Format = "{Sum:c}"; 
summary1.SummaryType = SummaryType.DoubleAggregate; 
GridSummaryColumn summary2 = new GridSummaryColumn(); 
summary2.Name = "Reserves"; 
summary2.MappingName = "Reserves"; 
summary2.Format = "{Sum:c}"; 
summary2.SummaryType = SummaryType.DoubleAggregate; 
summaryRow.SummaryColumns.Add(new GridSummaryColumn 
            Name = "Description", 
            CustomAggregate = new CustomAggregate(), 
            MappingName = "Description", 
            Format = "{totalSum}", 
            SummaryType = Syncfusion.Data.SummaryType.Custom 
GridSummaryColumn summary4 = new GridSummaryColumn(); 
summary4.Name = "Code"; 
summary4.MappingName = "Code"; 
summary4.Format = "{Count}"+"Count"; 
summary4.SummaryType = SummaryType.CountAggregate; 
datagrid.CaptionSummaryRow = summaryRow; 


Refer the below code snippet to write a custom aggregate to calculate the summary values based on custom logic for GridSummaryColumn.CustomAggregate property. 


public class CustomAggregate : ISummaryAggregate 
            public CustomAggregate() 
            public double totalSum { get; set; } 
            public Action<System.Collections.IEnumerable, string, System.ComponentModel.PropertyDescriptor> CalculateAggregateFunc() 
                        return (items, property, pd) => 
                                                var enumerableItems = items as IEnumerable<OrderInfo>; 
                                                if (pd.Name == "totalSum") 
                                                this.totalSum = enumerableItems.totalSum<OrderInfo>(q=>q.Incurred+q.Paid+q.Reserves); 
public static class LinqExtensions 
            public static double totalSum<T>(this IEnumerable<T> values, Func<T, double?> selector) 
                        double sum = 0; 
                        var count = values.Count(); 
                        foreach (var v in values ) 
                                    OrderInfo a = v as OrderInfo; 
                                                sum =  sum +a.Paid+a.Incurred+a.Reserves; 
                                   return sum; 



We have also prepared a sample based on this and you can download the same from the below location. 


Sample Link: http://www.syncfusion.com/downloads/support/forum/129931/ze/SummaryDemo-847017427 




Clint Anderson
Replied On April 11, 2017 08:37 PM UTC

Awesome that helps immensely.  Two more questions to see if it is possible.

Can I have a label that spans both the Codes and Desc columns?
Can I add UIButtons after this label?

Sivaraman Sivagurunathan [Syncfusion]
Replied On April 12, 2017 10:57 AM UTC

Hi Clint Anderson, 
Thanks for your patience.

We have checked your query to customize the grouping header. Currently we do not have support for custom template in grouping row, however we have already considered this requirement as a feature and planned to implement it in any of our upcoming releases. Please check our website periodically to get the list of features that are implemented.


Clint Anderson
Replied On April 12, 2017 03:48 PM UTC

Since I cannot create a custom template for the grouping header, is it possible for a group to have both a row with GroupCaptionTextFormat and a row with my custom GridSummaryRow which contains the calculations?

I have implemented my grid both ways.  With the GroupCaptionTextFormat, I am able to hide the column that I am grouping by and then display the relative text which spans 2-3 columns. With the GridSummaryRow, I can do the calculations, but I haven't been able to find a way to display the data from the grouping column in that row properly.

Divakar Subramaniam [Syncfusion]
Replied On April 13, 2017 10:58 AM UTC

Hi Clint Anderson, 
We have checked your query. Currently, it is not possible to show both the caption rows(row with CaptionSummaryRowText) and group summary rows(rows with summary calculation of particular group) in SfDataGrid. However, we have already logged a feature report for GroupSummary support in SfDataGrid and the same will be available from any of our upcoming releases. Since the feature is tentative, we can’t able to provide the exact timeline for the reported feature. Please check our website periodically to get the list of implemented features. 
If your requirement is different from what we understand, then please do revert us with some more detailed information regarding your query. 

Clint Anderson
Replied On April 28, 2017 04:25 PM UTC

Here is basically what I want to be able to do. (This is similar to what I have currently running in another grid package.)

There are basically 3 parts that I need for this functionality.  So far, I have been able to get 2 of them to work separately, but not together. 
I need to group rows by a column and then hide that column header from the grid. (In this case I am grouping by a customer, T. Monk.)
Also, I need to be able to calculate totals for certain (or all) number columns in that group and have the calculated value appear under the correct column.
Finally, I need some way to display buttons in the header row as well.  If nothing else, a single button would work.

I don't believe there is any way to do this currently, but something like this is what I would like to be able to do.


Dharmendar Dhanasekar [Syncfusion]
Replied On May 1, 2017 11:29 AM UTC

Hi Clint,

Thanks for contacting Syncfusion support.

Regarding your query “I need to group rows by a column and then hide that column header from the grid.”
You can group and hide that column using GridColumn.IsHidden property.

Regarding your query  “ I need to be able to calculate totals for certain (or all) number columns in that group and have the calculated value appear under the correct column.”
You can achieve this by using SfDataGrid.CaptionSummaryRow property. Using GridCaptionSummaryRow you can show summary information in the column by setting GridSummaryRow.ShowSummaryInRow to false and defining summary columns.  
GridSummaryRow summaryRow = new GridSummaryRow(); 
summaryRow.ShowSummaryInRow = false; 
new GridSummaryColumn() 
        Name = "CaptionSummary", 
        MappingName = "Salary", 
        Format = "{Sum:c}", 
        SummaryType = SummaryType.DoubleAggregate, 
dataGrid.CaptionSummaryRow = summaryRow; 

UG Link: https://help.syncfusion.com/xamarin-ios/sfdatagrid/summary#caption-summaries 

Regarding your query  “ I need some way to display buttons in the header row as well
Currently we don’t have support for this. However we have plans to support GroupTemplate in any of our upcoming release.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon