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

Key header in group

Thread ID:

Created:

Updated:

Platform:

Replies:

142710 Feb 15,2019 06:07 PM UTC Feb 20,2019 06:24 AM UTC WPF 3
loading
Tags: SfDataGrid
Rafal
Asked On February 15, 2019 06:07 PM UTC

Hello,
Now I have such a basic view:


After grouping by 'Klient' I have:


And after expand:


I would like to get something like that:



For the next levels of groups I would like to achieve a similar effect.

How to do it?

Best regards,
Rafal

Jagadeesan Pichaimuthu [Syncfusion]
Replied On February 18, 2019 12:09 PM UTC

Hi Rafal, 
 
Thank you for contacting Syncfusion support. 
 
We have analyzed your query and you can achieve your requirement “To display the Grouped column Key in CaptionSummaryRow Column” by overriding the CaptionSummaryCellRender. Please refer the below code snippets. 
 
public class CustomCaptionSummaryCellRenderer : GridCaptionSummaryCellRenderer 
{ 
    public override void OnInitializeEditElement(DataColumnBase dataColumn, GridCaptionSummaryCell uiElement, object dataContext) 
    { 
        if (dataContext is Group) 
        { 
            var groupRecord = dataContext as Group; 
            var mappingName = dataColumn.GridColumn.MappingName; 
            var groupedColumn = this.GetGroupedColumn(groupRecord); 
 
            if (mappingName == groupedColumn.MappingName) 
                uiElement.Content = groupRecord.Key; 
            else 
                uiElement.Content = SummaryCreator.GetSummaryDisplayText(groupRecord.SummaryDetails, 
                    dataColumn.GridColumn.MappingName, this.DataGrid.View); 
        } 
    } 
 
    public override void OnUpdateEditBinding(DataColumnBase dataColumn, GridCaptionSummaryCell element, object dataContext) 
    { 
        if (element.DataContext is Group && this.DataGrid.View.GroupDescriptions.Count > 0) 
        { 
            var groupRecord = element.DataContext as Group; 
            //get the column which is grouped. 
            var groupedColumn = this.GetGroupedColumn(groupRecord); 
            var mappingName = dataColumn.GridColumn.MappingName; 
 
            if (mappingName == groupedColumn.MappingName) 
                element.Content = groupRecord.Key; 
            else 
                element.Content = SummaryCreator.GetSummaryDisplayText(groupRecord.SummaryDetails, 
                    dataColumn.GridColumn.MappingName, this.DataGrid.View); 
        } 
    } 
 
    // Method to get the Grouped Column. 
    private GridColumn GetGroupedColumn(Group group) 
    { 
        var groupDesc = this.DataGrid.View.GroupDescriptions[group.Level - 1] as PropertyGroupDescription; 
        foreach (var column in this.DataGrid.Columns) 
        { 
            if (column.MappingName == groupDesc.PropertyName) 
            { 
                return column; 
            } 
        } 
        return null; 
    } 
        
} 
 
Please find the sample from the below location. 
 
Screenshot: 
 
 
Please refer the below KB to get more details about CaptionSummaryCell renderer customization. 
 
 
Regards, 
Jagadeesan 


Rafal
Replied On February 19, 2019 12:35 PM UTC

Thank you very much :).

Best regards,
Rafal

Jayaleshwari N [Syncfusion]
Replied On February 20, 2019 06:24 AM UTC

Hi Rafal, 
 
Thanks for the update. Please get in touch if you would require further assistance. 
 
Regards, 
Jayaleshwari N 


CONFIRMATION

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

;