Class DataGridSummaryColumn
Represents a class that defines the summary calculation based on a column.
Inheritance
Namespace: Syncfusion.Maui.DataGrid
Assembly: Syncfusion.Maui.DataGrid.dll
Syntax
public class DataGridSummaryColumn : Object, ISummaryColumn, IDisposable
Constructors
DataGridSummaryColumn()
Declaration
public DataGridSummaryColumn()
Properties
CustomAggregate
Gets or sets the custom aggregate of the DataGridSummaryColumn.
Declaration
public ISummaryAggregate CustomAggregate { get; set; }
Property Value
Type |
---|
ISummaryAggregate |
Remarks
DataGrid provides the built in aggregate types for calculating the values for the summary column in the SummaryType of theDataGridSummaryColumn.The user can implement their own aggregate function when the built in aggregate function does not meet his requirement using this property.When the user defines his own aggregate function in the CustomAggregate, set the SummaryType as Custom.
Examples
<ContentPage.Resources>
<local:CustomAggregate x:Key="customAggregate"></local:CustomAggreate>
</ContentPage.Resources>
<sfGrid:SfDataGrid.TableSummaryRows>
<sfGrid:DataGridTableSummaryRow Title="Standard Deviation:{TableSummary}" ShowSummaryInRow = "True">
<sfGrid:DataGridTableSummaryRow.SummaryColumns>
<sfGrid:DataGridSummaryColumn Name="TableSummary" CustomAggregate="{StaticResource customAggregate}" Format="{{StdDev}" MappingName="OrderID" SummaryType="Custom"/>
</sfGrid:DataGridTableSummaryRow.SummaryColumns>
</sfGrid:DataGridTableSummaryRow>
public class CustomAggregate : ISummaryAggregate
{
public CustomAggregate()
{
}
public double StdDev { 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 == "StdDev")
{
this.StdDev = enumerableItems.StdDev<OrderInfo>(q => q.OrderID);
}
};
}
}
public static class LinqExtensions
{
public static double StdDev<T>(this IEnumerable<T> values, Func<T, double?> selector)
{
double value = 0;
var count = values.Count();
if (count > 0)
{
double? avg = values.Average(selector);
double sum = values.Select(selector).Sum(d =>
{
if (d.HasValue)
{
return Math.Pow(d.Value - avg.Value, 2);
}
return 0.0;
});
value = Math.Sqrt((sum) / (count - 1));
}
return value;
}
}
<syncfusion:DataGridSummaryColumn Name="TotalSalary"
Format="{}{Sum:C0}"
MappingName="Salary"
SummaryType="Custom" />
DependentColumnNames
Gets or sets the dependent column names for this summary column. It refreshes the summary column data when any value of its dependent columns is changed.
Declaration
public string DependentColumnNames { get; set; }
Property Value
Type |
---|
System.String |
Format
Gets or sets the format to be applied to the summary value.
Declaration
public string Format { get; set; }
Property Value
Type |
---|
System.String |
MappingName
Gets or sets the MappingName column, that is used for summary calculation.
Declaration
public string MappingName { get; set; }
Property Value
Type |
---|
System.String |
Name
Gets or sets the name of the summary column that helps to denote the DataGridSummaryColumn in Title
Declaration
public string Name { get; set; }
Property Value
Type |
---|
System.String |
SummaryMode
Gets or sets a value that decides whether summary calculation is processed based on display value in case of indexer and complex properties or default value in case of CLR properties of the column.
Declaration
public DataReflectionMode SummaryMode { get; set; }
Property Value
Type |
---|
DataReflectionMode |
SummaryType
Gets or sets the type of the summary column for calculating values.
Declaration
public SummaryType SummaryType { get; set; }
Property Value
Type |
---|
SummaryType |
Remarks
DataGrid provides the built in aggregate types for calculating the values for the summary column in the SummaryType.User can implement their own aggregate function when the built in aggregate function does not meet his requirement using CustomAggregate property.
Template
Gets or sets the template that is used to display the contents of a DataGridSummaryColumn.
Declaration
public DataTemplate Template { get; set; }
Property Value
Type |
---|
Microsoft.Maui.Controls.DataTemplate |
Methods
Dispose()
Releases the resources used by the component.
Declaration
public void Dispose()
Dispose(Boolean)
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |