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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to customize the CaptionSummaryCell text in the SfDataGrid?

In the SfDataGrid, GridCaptionSummaryCell displays the GroupCaption and the Caption Summary value. You can refer here to know more about the Caption Summaries. By default, the GroupCaption text is displayed in the {ColumnName}: {Key} – {ItemsCount} Items format. You can customize the GroupCaptionText with the help of the GroupCaptionTextFormat. You can refer here to know more about the GroupCaptionTextFormat.

By default, the CaptionSummaryCell text is displayed as follows.

C:\Users\arshiazeba\Desktop\image1.png

Figure 1: CaptionSummaryCell text – Default format

By using the GroupCaptionTextFormat, you cannot modify the GroupName, Group KEY, and itemscount in different formats for the available groups based on some conditions. To achieve this, you need to derive a new class from the GridCaptionSummaryCellRenderer and override the OnInitializeEditElement () and OnUpdateEditBinding () methods in the derived CustomCaptionSummarycellRenderer. You can refer to the following code example to derive a new class from the GridCaptionSummaryCellRenderer.

C#

Group KEY and items (Default Text) in the CaptionSummaryCell text are displayed in different formats based on the itemscount. For example, in the code example, Group KEY 1000 is changed into one thousand based on the group name and the default text, items, is changed into entries in the group or elements in the group based on the itemscount.

OnInitializeEditElement method is used to initialize the content of the CaptionSummaryCell by using the grouped column details and it is invoked while creating a SpannedDataColumn in the CaptionSummaryRow.

You can refer to the following code example to override the OnInitializeEditElement ().

C#

In the OnInitializeEditElement method, CaptionSummaryCell text can be customized by using grouped column name, Group KEY and the itemscount. By using GetGroupedColumn method, the grouped column is obtained. ShowSummaryInRow property in GridSummaryRow is used to decide whether the summary value is displayed in the specific row or column. By using GetDisplayTextForRow method and GetDisplayText method, CaptionSummaryCell text is displayed based on the ShowSummaryInRow property. You can refer here to know more about the GridSummaryRow properties.

OnUpdateEditBinding method is used to update the CaptionSummaryCell text when there is a change in grouping like itemscount, Group KEY, and grouped column name; and it is invoked when the CaptionSummaryRow is updated and also whenever the grid is refreshed. You can refer to the following code example to override the OnUpdateEditBinding ().

C#

You can refer to the following code example for GetGroupedColumn ().

C#

You can refer to the following code example for GetCustomizedCaptionText ().

C#

In the GetCustomizedCaptionText method, the CaptionSummaryCell text is framed and customized text is returned. You can refer to the following code example to remove the default GridCaptionSummaryCellRenderer and add the derived GridCaptionSummaryCellRenderer to the renderers’ collection in the SfDataGrid.

C#

After the customization of the CaptionSummaryCell text, the CaptionSummaryCell is displayed as follows.

     Figure 2: Customized CaptionSummaryCell text

In the above screenshot, the Group KEY is changed as One Thousand instead of 1000, thousand and two instead of 1002 and also the default text, items, is changed as entries in the group, elements in the group based on the itemscount.

You can refer to the sample from following location.

Samples

WPF

WinRT

Silverlight

 

Article ID: Published Date: Last Revised Date: Platform: Control: Product Version:
3249 01/19/2015 12/15/2015 WPF SfDataGrid 12.4.0.24
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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