Is it possible to dynamically create aggregate columns to match the locations with dynamic columns in footer of the Grid?

We can render the aggregated Grid with dynamic columns with the below code snippet:

<SfGrid DataSource="@OrderData">

<GridEditSettings AllowEditing="true" AllowAdding="true" AllowDeleting="true">GridEditSettings>

<GridColumns>

@foreach (var prop in typeof(Order).GetProperties())

{

<GridColumn Field="@prop.Name" IsPrimaryKey="@(prop.Name == "OrderID")" AllowEditing="@prop.CanWrite">GridColumn>

}

GridColumns>

<GridAggregates>

<GridAggregate>

<GridAggregateColumns>

@foreach (var prop in typeof(Order).GetProperties())

{

var a = prop;

if (prop.PropertyType.FullName == "System.Nullable`1[[System.Double, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]")

{

<GridAggregateColumn Field[email protected] Type="AggregateType.Sum" Format="C2">

<FooterTemplate>

@{

var aggregate = (context as AggregateTemplateContext);

<div>

<p>Sum: @aggregate.Sump>

div>

}

FooterTemplate>

GridAggregateColumn>

}

}

GridAggregateColumns>

GridAggregate>

GridAggregates>

SfGrid>


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/AggregatedynnamicCol2092625557-1284070402

Reference: https://blazor.syncfusion.com/documentation/datagrid/columns/#dynamic-column-building


Loader.
Up arrow icon