Grid not working with aggregates
I'm attempting to set up a playground link to submit a ticket for another issue, but I'm running into a problem where the grid won't show any items if I define the <GridAggregates> node. If I comment it out (as it is in the link), the grid will display. I'm not sure why its not working.
Playground link: https://blazorplayground.syncfusion.com/VDLTZUVvGnLSprTx
You have problem with
Hi Josh,
Based on your requirement, we
would like to inform you that aggregation will work based on the column field.
Therefore, the loop field isn't present in the Order model class, which is why
you have faced the issue. To achieve your requirement, we suggest using a
custom aggregate. Kindly refer to the below code snippet and sample
for your reference.
|
@using Syncfusion.Blazor.Grids
------ @foreach (var col in FreightCols) { <GridAggregateColumn Field="@($"Freight_{col}")" Type="AggregateType.Custom"> <FooterTemplate> <div> <p>Sum: @CustomAggregateFunction(col)</p> </div> </FooterTemplate> </GridAggregateColumn> } </GridAggregateColumns> </GridAggregate> </GridAggregates> </SfGrid> }
@code { internal bool Loaded; internal List<string> FreightCols = new() { "1", "2", "3" };
public static List<Order> OrderData = GetOrders();
private double CustomAggregateFunction(string col) { // Find the index of the column in FreightCols int colIndex = FreightCols.IndexOf(col);
// Sum up the values in the specified column double sum = OrderData.Sum(order => order.Freights[colIndex]);
return sum; }
|
Regards,
Prathap S
- 2 Replies
- 3 Participants
-
JB Josh Barrineau
- Mar 28, 2024 09:15 PM UTC
- Mar 29, 2024 10:31 AM UTC