Group aggregates still not working (3 years after I first found problems with them)

Syncfusion.Blazor 25.1.39

SfGrid, trying to get a group caption showing the sum of a column.

...

<GridAggregates>
    <GridAggregate>
        <GridAggregateColumns>
            <GridAggregateColumn Field="Quantity1" Type="Syncfusion.Blazor.Grids.AggregateType.Sum">
                <GroupCaptionTemplate Context="aggregateContext">
                    @{
                        var aggregate = (aggregateContext as AggregateTemplateContext);
                        <div>
                            <p>Total Stock : @aggregate.Sum</p>
                        </div>
                    }
                </GroupCaptionTemplate>
            </GridAggregateColumn>
        </GridAggregateColumns>
    </GridAggregate>
</GridAggregates>

...

2024-07-08_134145.png

Two problems found :

  1. GroupCaptionTemplate does not show my text - only the default text is shown in the group caption area, not my text including the sum.  Note that GroupFooterTemplate does work as expected!
  2. The aggregate still does not work properly with paging - the aggregate only covers rows on the current page, not all rows within the group (that could span several pages).  The grid is using a List<T> as its DataSource, so all data is local and available.  There have been a number of forum posts over the years complaining about this and this problem still persists, despite talk about DisablePageWiseAggregates and EnableLazyLoading, neither of which solve the problem.

Please advise what can be done to address these problems.

Thanks
Paul



5 Replies

PS Prathap Senthil Syncfusion Team July 8, 2024 12:19 PM UTC

Hi Paul,

We are unable to reproduce the reported issue “GroupCaptionTemplate does not show my text” when attempting to reproduce the issue in the version 26.1.39 . For your reference we have attached screen shot and simple sample .So, to
further proceed with the reporting problem, we require some additional clarification from your end. Please share the below details to proceed further at our end.

  • To analyze the reported issue, could you please share a simple and reproducible sample that demonstrates the problem? This will assist us in identifying the issue more efficiently and providing a resolution.
  • If possible, kindly share your attempt to replicate the issue using the attached simple sample.


Above-requested details will be very helpful in validating the reported query at our end and providing a solution as early as possible. Thanks for your understanding.

Sample: https://blazorplayground.syncfusion.com/embed/BNVpjmXbAacGEQRe?appbar=true&editor=true&result=true&errorlist=true&theme=bootstrap5

Regarding the 'DisablePagewiseAggregate' feature, we would like to clarify that currently we don’t have support for this feature. Thanks for your understanding.

Regards,
Prathap Senthil



PA Paul July 8, 2024 11:21 PM UTC

I have found the cause of the first problem - the aggregate is not shown if it is the left-most column being aggregated!

Presumably the standard group caption text overrides this.

Apart from simply moving the column position, is there a way I could make the aggregate text appear above the left-most column?


As for the second problem, if you really are not supporting a correct group aggregate over the entire data set then that is ... disappointing.

This makes it useless for anything except very small sets of data.

Instead, I will have to perform a lookup on a summary hashset based on the group key, or something similar.

Is solving this problem on Syncfusion's roadmap?


Thanks

Paul





PS Prathap Senthil Syncfusion Team July 11, 2024 01:09 PM UTC

We have confirmed this a breaking issue and logged the defect report “Aggregate not shown in group caption row when left-most column is aggregated.” for the same and this fix will be included in our upcoming patch release.


You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.    
  

Aggregate not shown in group caption row when left-most column is aggregated in Blazor | Feedback Portal (syncfusion.com)

Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization”

We will get back to you once the release is rolled out. Until then we appreciate your patience

Regarding the DisablePageWiseAggregates with EnableLazyLoading, we would like to clarify that when EnableLazyLoading is enabled, the grouped header will be loaded with the initial set of records and rendered during the initial rendering itself. However, the actual records will load only upon expanding the groups. This behavior is default and hence, it is not feasible to achieve your requirement of aggregating only the current row records



PS Prathap Senthil Syncfusion Team August 21, 2024 06:11 AM UTC

We regret that we were unable to include this fix in yesterday's patch release. While addressing the issue, we encountered some complexities and need to ensure the solution was thoroughly tested with various test cases. However, we want to assure you that the fix will be included in our next weekly patch release, scheduled for on or before August 27th, 2024. We appreciate your patience and understanding during this time. Thank you



PS Prathap Senthil Syncfusion Team August 28, 2024 05:18 AM UTC

Thanks for your patience.

We are glad to announce that, we have included the fix for the “Aggregate not shown in group caption row when left-most column is aggregated.”  in our 26.2.11 release.  So please upgrade to our latest version of Syncfusion NuGet package to resolve the reported issue. Please find the NuGet package for latest fixes and features from below.


NuGet : https://www.nuget.org/packages/Syncfusion.Blazor.Grid


RootCause: Aggregate value not rendered along with group caption.

.

Corrective Actions Taken: Created an object for aggregate value to get aggregate in Caption Template Context.

Please Note: We have fixed both the sample and the source code. The problem occurred because the aggregate value was not displayed in the leftmost grouped column due to our previous implementation's inability to render the aggregate value within the group caption. This issue has now been resolved by integrating the caption template context into the group caption via the aggregate template context property in the source code. Please refer to the modified code snippet and sample provided below for further reference.


  <GridGroupSettings Columns=@GroupOptions ShowGroupedColumn="false">

        <CaptionTemplate>

            @{

                var captionData = (context as Syncfusion.Blazor.Grids.CaptionTemplateContext);

                var val2 = captionData.GroupAggregates as AggregateTemplateContext;

                var collection = new Dictionary<string, object>

                    {

                        ["sum"] = val2.Sum,

                        ["average"] = val2.Average,

                        ["count"] = val2.Count,

                        ["custom"] = val2.Custom,

                        ["truecount"] = val2.TrueCount,

                        ["falseCount"] = val2.FalseCount,

                        ["max"] = val2.Max,

                        ["min"] = val2.Min

                    };

 

                var groupKey = captionData.Key;

                var FieldName = captionData.Field;

                var itemCount = captionData.Count;

                var groupCaption = $"{captionData.Field}: {groupKey} - {itemCount} items";

                if (val2.Field != null)

                {

                    if (val2.Count != null)

                    {

                        <div>@groupCaption Counting: @collection["count"]</div>

                    }

                    else if (val2.Min != null)

                    {

                        <div>@groupCaption Minimum: @collection["min"]</div>

                    }

                    else if (val2.Max != null)

                    {

                        <div>@groupCaption Maximum: @collection["max"]</div>

                    }

                    else if (val2.TrueCount != null)

                    {

                        <div>@groupCaption TrueCounting: @collection["truecount"]</div>

                    }

                    else if (val2.FalseCount != null)

                    {

                        <div>@groupCaption FalseCounting: @collection["falsecount"]</div>

                    }

                    else if (val2.Sum != null)

                    {

                        <div>@groupCaption Sum Value: @collection["sum"]</div>

                    }

                    else if (val2.Average != null)

                    {

                        <div>@groupCaption Average: @collection["average"]</div>

                    }

                    else

                    {

                        <div>@groupCaption Customing: @collection["custom"]</div>

                    }

                }

                else

                {

                    <div>

                        <div>@groupCaption</div>

                    </div>

                }

            }

        </CaptionTemplate>

    </GridGroupSettings>

 


Sample: Syncfusion Blazor Playground: Write, Edit, Compile & Share Code for Blazor Components


Loader.
Up arrow icon