Class GridCaptionSummaryCellRenderer
Represents a class that maintains the rendering of GridCaptionSummaryCell.
Inheritance
System.Object
GridCaptionSummaryCellRenderer
Inherited Members
Namespace: Syncfusion.UI.Xaml.DataGrid.Renderers
Assembly: Syncfusion.Grid.WinUI.dll
Syntax
public class GridCaptionSummaryCellRenderer : GridVirtualizingCellRenderer<GridCaptionSummaryCell, GridCaptionSummaryCell>, IGridCellRenderer, IDisposable
Examples
this.sfDataGrid.CellRenderers.Remove("CaptionSummary");
this.sfDataGrid.CellRenderers.Add("CaptionSummary", new GridCaptionSummaryCellRendererExt());
public class GridCaptionSummaryCellRendererExt : GridCaptionSummaryCellRenderer
{
public override void OnUpdateEditBinding(Syncfusion.UI.Xaml.DataGrid.DataColumnBase dataColumn, Syncfusion.UI.Xaml.DataGrid.GridCaptionSummaryCell element, object dataContext)
{
if (element.DataContext is Group && this.DataGrid.View.GroupDescriptions.Count > 0)
{
var groupRecord = element.DataContext as Group;
var groupedColumn = this.GetGroupedColumn(groupRecord);
if (this.DataGrid.CaptionSummaryRow == null)
{
if (this.DataGrid.View.GroupDescriptions.Count < groupRecord.Level)
return;
//Set the CaptionSummaryCell text as customized.
element.Content = GetCustomizedCaptionText(groupedColumn.HeaderText, groupRecord.Key, groupRecord.ItemsCount);
}
else if (this.DataGrid.CaptionSummaryRow.ShowSummaryInRow)
{
element.Content = SummaryCreator.GetSummaryDisplayTextForRow(groupRecord.SummaryDetails, this.DataGrid.View, groupedColumn.HeaderText);
}
else
element.Content = SummaryCreator.GetSummaryDisplayText(groupRecord.SummaryDetails, dataColumn.GridColumn.MappingName, this.DataGrid.View);
}
}
private GridColumn GetGroupedColumn(Group group)
{
var groupDesc = this.DataGrid.View.GroupDescriptions[group.Level - 1];
foreach (var column in this.DataGrid.Columns)
{
if (column.MappingName == groupDesc.PropertyName)
{
return column;
}
}
return null;
}
private string GetCustomizedCaptionText(string columnName, object groupName, int itemsCount)
{
//entryText - instead of "Items", the entryText is assigned to Customize the CaptionSummaryCell Text.
string entryText = string.Empty;
if (itemsCount < 20)
entryText = "entries in the Group";
else if (itemsCount < 40)
entryText = "elements in the Group";
else if (itemsCount < 60)
entryText = "list in the Group";
else
entryText = "items in the Group";
if (groupName.ToString().Equals("1001"))
groupName = "Thousand and One";
else if (groupName.ToString().Equals("1002"))
groupName = "Thousand and Two";
else if (groupName.ToString().Equals("1004"))
groupName = "Thousand and Four";
return string.Format("{0}: {1} - {2} {3}", columnName, groupName, itemsCount, entryText);
}
}
Constructors
GridCaptionSummaryCellRenderer()
Initializes a new Instance of GridCaptionSummaryCellRenderer class.
Declaration
public GridCaptionSummaryCellRenderer()
Methods
InitializeCellStyle(DataColumnBase, Object)
Initializes the custom style for cell when the corresponding api's and selectors are used.
Declaration
protected override void InitializeCellStyle(DataColumnBase dataColumn, object record)
Parameters
Type | Name | Description |
---|---|---|
DataColumnBase | dataColumn | Specifies the corresponding DataColumnBase. |
System.Object | record | Specifies the corresponding record to initialize cell style. |
Overrides
Syncfusion.UI.Xaml.DataGrid.Renderers.GridVirtualizingCellRendererBase<Syncfusion.UI.Xaml.DataGrid.GridCaptionSummaryCell, Syncfusion.UI.Xaml.DataGrid.GridCaptionSummaryCell>.InitializeCellStyle(Syncfusion.UI.Xaml.DataGrid.DataColumnBase, System.Object)
OnInitializeEditElement(DataColumnBase, GridCaptionSummaryCell, Object)
Initializes the binding editor for corresponding column.
Declaration
public override void OnInitializeEditElement(DataColumnBase dataColumn, GridCaptionSummaryCell uiElement, object dataContext)
Parameters
Type | Name | Description |
---|---|---|
DataColumnBase | dataColumn | Specifies the corresponding DataColumnBase. |
GridCaptionSummaryCell | uiElement | Specifies the corresponding UIElement. |
System.Object | dataContext | Specifies the dataContext of the cell. |
Overrides
Syncfusion.UI.Xaml.DataGrid.Renderers.GridVirtualizingCellRenderer<Syncfusion.UI.Xaml.DataGrid.GridCaptionSummaryCell, Syncfusion.UI.Xaml.DataGrid.GridCaptionSummaryCell>.OnInitializeEditElement(Syncfusion.UI.Xaml.DataGrid.DataColumnBase, Syncfusion.UI.Xaml.DataGrid.GridCaptionSummaryCell, System.Object)
OnUpdateEditBinding(DataColumnBase, GridCaptionSummaryCell, Object)
Updates the binding for editor control of corresponding column.
Declaration
public override void OnUpdateEditBinding(DataColumnBase dataColumn, GridCaptionSummaryCell element, object dataContext)
Parameters
Type | Name | Description |
---|---|---|
DataColumnBase | dataColumn | Specifies the corresponding DataColumnBase. |
GridCaptionSummaryCell | element | Specifies the corresponding GridCaptionSummaryCell. |
System.Object | dataContext | Specifies the data context of the cell. |
Overrides
Syncfusion.UI.Xaml.DataGrid.Renderers.GridVirtualizingCellRenderer<Syncfusion.UI.Xaml.DataGrid.GridCaptionSummaryCell, Syncfusion.UI.Xaml.DataGrid.GridCaptionSummaryCell>.OnUpdateEditBinding(Syncfusion.UI.Xaml.DataGrid.DataColumnBase, Syncfusion.UI.Xaml.DataGrid.GridCaptionSummaryCell, System.Object)
Implements
System.IDisposable