Summary rows doesn't work with filtered virtual rows

Hello,
We have created an example project that has a data grid virtual row and filtering is enabled. Imagine that there are two columns which are product and amount.
Amount column has a summary row. When we filter a product, the summary row doesn't refresh.
Could you please send an example about this issue.
Best regards.

3 Replies 1 reply marked as answer

JP Jeevakanth Palaniappan Syncfusion Team May 4, 2021 11:23 AM UTC

Hi Ozgur, 

Greetings from Syncfusion support. 

We have checked your query and we would like to inform you that by default the aggregate will not be refreshed on performing filtering. You can only achieve it by using the custom aggregate feature of thr grid. Based on your requirement, we have prepared a sample. Please find the below code snippet and the sample for your reference. 

<SfGrid @ref="Grid" DataSource="@GridData" Height="600" EnableVirtualization="true" AllowFiltering="true"> 
    <GridEvents TValue="Order" OnActionComplete="ActionComplete"></GridEvents> 
    <GridAggregates> 
        <GridAggregate> 
            <GridAggregateColumns> 
                <GridAggregateColumn Field=@nameof(Order.Freight) Type="AggregateType.Sum" Format="C2"> 
                    <FooterTemplate> 
                        @{ 
                            <div> 
                                <p>Sum: @GetSumAggregate()</p> 
                            </div> 
                        } 
                    </FooterTemplate> 
                </GridAggregateColumn> 
            </GridAggregateColumns> 
        </GridAggregate> 
    </GridAggregates> 
    <GridColumns> 
        <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
    </GridColumns> 
</SfGrid> 
 
@code{ 
    public static List<Order> GridData { get; set; } 
    SfGrid<Order> Grid { get; set; } 
    List<Order> FilteredRecords = GridData; 
    public async Task ActionComplete(ActionEventArgs<Order> args) { 
        if (args.RequestType == Syncfusion.Blazor.Grids.Action.Filtering) { 
            FilteredRecords = (await Grid.GetFilteredRecords()) as List<Order>; 
        } else if (args.RequestType == Syncfusion.Blazor.Grids.Action.ClearFiltering) { 
            FilteredRecords = GridData; 
        } 
    } 
    public string GetSumAggregate() { 
        return (FilteredRecords.Sum(x=>x.Freight)).ToString(); 
    } 
} 



Please get back to us if you have any other queries. 

Regards, 
Jeevakanth SP. 


Marked as answer

ÖA Özgür ALTUNSÖGÜT May 4, 2021 11:45 AM UTC

Hello,
By default, if virtual row is not enabled, aggregate function works as aspected. But if you enable virtual row, after filtering summary rows not refresh.
We have solved this to disable virtual row property in onActionComplete event and reactivate after event completed.
The problem is solved for us. Thank you.


JP Jeevakanth Palaniappan Syncfusion Team May 5, 2021 05:46 AM UTC

Hi Ozgur, 
 
Thanks for the update. We are glad that the reported problem is resolved at your end. Please get back to us if you have any other queries. 

Regards, 
Jeevakanth SP. 


Loader.
Up arrow icon