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. Image for the cookie policy date

Custom datagrid group header

Is it possible to create a custom datagrid grouping header similar to the datasource GroupDescriptors for the listview?  Please see the highlighted code in the view model class below. 



I would like to display the TestTypeShortDescrption in the grouping header rather then the TestTypeID.


5 Replies

SP Subburaj Pandian Veluchamy Syncfusion Team February 27, 2019 12:36 PM UTC

Hi Paul, 
 
Thank you for contacting Syncfusion support. 
 
Based on the provide information, your requirement of “Displaying the Group header description based on the given condition” can be achieved using the ISummaryAggregate and setting value to the CaptionSummaryRow.  
 
We have prepared sample for the same, please find the sample by the following link. 
 
Sample link: GridGroupSummarySample 
 
In the sample, we have displayed the group items count and date based on the group item values. 
 
You can refer regarding the same in our user guide documentation by the following link, 
 
 
We hope this helps. Please let us know, if you have any query. 
 
Regards,
Subburaj Pandian V  
 



PD Paul Dietz February 27, 2019 05:38 PM UTC

Thank you for the reply to my question.   The sample code provided was not of much help, but a customaggregate may work.  Do you have any example code of returning a child string.  The function needs to return the child testypeinfo short desc of the parent testinfo based on testtypeid.


SP Subburaj Pandian Veluchamy Syncfusion Team February 28, 2019 01:01 PM UTC

Hi Paul, 
  
Thank you for update. 
  
We checked your requirement “How to display another column detail in caption summary row” and prepared sample based on your requirement. We have Grouped OrderID column and displayed Cutomer Column details in caption summary row. Please refer the following code snippet for your reference, 
  
[C#] 
dataGrid.GroupColumnDescriptions.Add(new GroupColumnDescription() 
{ 
    ColumnName = "OrderID" 
}); 
  
GridSummaryRow summaryRow = new GridSummaryRow(); 
summaryRow.Title = "Short Description : {CaptionSummary}"; 
summaryRow.ShowSummaryInRow = true; 
summaryRow.SummaryColumns.Add(new GridSummaryColumn 
{ 
    Name = "CaptionSummary", 
    // Defining Custom Aggregate. 
    CustomAggregate = new CustomAggregate(), 
    MappingName = "OrderID", 
    Format = "{CustomString}", 
    SummaryType = Syncfusion.Data.SummaryType.Custom 
}); 
dataGrid.CaptionSummaryRow = summaryRow; 
  
  
// Aggregate class. 
public class CustomAggregate : ISummaryAggregate 
{ 
    public CustomAggregate() 
    { 
    } 
  
    public string CustomString { getset; } 
  
    public Action<System.Collections.IEnumerable, string, PropertyInfo> CalculateAggregateFunc() 
    { 
        return (items, property, pd) => 
        { 
            var enumerableItems = items as IEnumerable<OrderInfo>; 
            if (pd.Name == "CustomString") 
            { 
                var value = enumerableItems.First<OrderInfo>().Customer; 
                var count = enumerableItems.Count(); 
                this.CustomString = value.ToString() + "-" + count + " Items"; 
            } 
        }; 
    } 
} 
  
We have also prepared sample and attached in following reference. 
  
  
We hope this helps. Please lets us know, if you need further assistance. 
 
Regards,
Subburaj Pandian V
 



PD Paul Dietz replied to Subburaj Pandian Veluchamy February 28, 2019 07:58 PM UTC

Hi Paul, 
  
Thank you for update. 
  
We checked your requirement “How to display another column detail in caption summary row” and prepared sample based on your requirement. We have Grouped OrderID column and displayed Cutomer Column details in caption summary row. Please refer the following code snippet for your reference, 
  
[C#] 
dataGrid.GroupColumnDescriptions.Add(new GroupColumnDescription() 
{ 
    ColumnName = "OrderID" 
}); 
  
GridSummaryRow summaryRow = new GridSummaryRow(); 
summaryRow.Title = "Short Description : {CaptionSummary}"; 
summaryRow.ShowSummaryInRow = true; 
summaryRow.SummaryColumns.Add(new GridSummaryColumn 
{ 
    Name = "CaptionSummary", 
    // Defining Custom Aggregate. 
    CustomAggregate = new CustomAggregate(), 
    MappingName = "OrderID", 
    Format = "{CustomString}", 
    SummaryType = Syncfusion.Data.SummaryType.Custom 
}); 
dataGrid.CaptionSummaryRow = summaryRow; 
  
  
// Aggregate class. 
public class CustomAggregate : ISummaryAggregate 
{ 
    public CustomAggregate() 
    { 
    } 
  
    public string CustomString { getset; } 
  
    public Action<System.Collections.IEnumerable, string, PropertyInfo> CalculateAggregateFunc() 
    { 
        return (items, property, pd) => 
        { 
            var enumerableItems = items as IEnumerable<OrderInfo>; 
            if (pd.Name == "CustomString") 
            { 
                var value = enumerableItems.First<OrderInfo>().Customer; 
                var count = enumerableItems.Count(); 
                this.CustomString = value.ToString() + "-" + count + " Items"; 
            } 
        }; 
    } 
} 
  
We have also prepared sample and attached in following reference. 
  
  
We hope this helps. Please lets us know, if you need further assistance. 
 
Regards,
Subburaj Pandian V
 


Added test type description to the test info collection, so the grouping now shows the test type description.  




SP Subburaj Pandian Veluchamy Syncfusion Team March 1, 2019 06:10 AM UTC

Hi Paul,  
  
Thank you for the update. We are happy that the given solution meets your requirement. 
 
Please let us know, if you need any further assistance.  
 
Regards,
Subburaj Pandian V  


Loader.
Live Chat Icon For mobile
Up arrow icon