How to get Footer Summary value in Grid

I have an grid in batch mode.I would like to know how to get footer summary value via code 

1 Reply 1 reply marked as answer

RN Rahul Narayanasamy Syncfusion Team April 13, 2021 01:35 PM UTC

Hi Ismail, 

Greetings from Syncfusion. 

Query: How to get Footer Summary value in Grid  

We have validated your query and you want to get footer aggregate value. Could you please share information about why did you want to get the footer aggregate value? 

Also, we would like to inform you that currently we don’t have any direct support to get the footer aggregate value. But you can calculate the footer aggregate value by using PerformAggregation method and get the footer aggregate value. Find the below code snippets and sample for your reference. 

@using Syncfusion.Blazor.Data 
@using Syncfusion.Blazor.Grids 
 
<button @onclick="Calculate">Get aggregate</button> 
 
<SfGrid @ref="Grid" DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Delete", "Update", "Cancel" })"> 
    <GridPageSettings PageSize="8"></GridPageSettings> 
    <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Batch"></GridEditSettings> 
    <GridAggregates> 
        <GridAggregate> 
            <GridAggregateColumns> 
                <GridAggregateColumn Field=@nameof(Order.Freight) Type="AggregateType.Sum" Format="C2"> 
                    <FooterTemplate> 
                        @{ 
                            var aggregate = (context as AggregateTemplateContext); 
                            <div> 
                                <p>Sum: @aggregate.Sum</p> 
                            </div> 
                        } 
                    </FooterTemplate> 
                </GridAggregateColumn> 
            </GridAggregateColumns> 
        </GridAggregate> 
        <GridAggregate> 
            <GridAggregateColumns> 
                <GridAggregateColumn Field=@nameof(Order.Freight) Type="AggregateType.Average" Format="C2"> 
                    <FooterTemplate> 
                        @{ 
                            var aggregate = (context as AggregateTemplateContext); 
                            <div> 
                                <p>Average: @aggregate.Average</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{ 
    SfGrid<Order> Grid { get; set;} 
    public List<Order> Orders { get; set; } 
    public List<Syncfusion.Blazor.Data.Aggregate> aggregates = new List<Syncfusion.Blazor.Data.Aggregate>(); 
 
    protected override void OnInitialized() 
    { 
        Orders = Enumerable.Range(1, 75).Select(x => new Order() 
        { 
            . . . 
 
        aggregates.Add(new Aggregate() { Field = "Freight", Type = "Sum" }); 
        aggregates.Add(new Aggregate() { Field = "Freight", Type = "Average" });   //define list of aggregate  
    } 
 
    . . . 
 
    public void Calculate() 
    { 
        var aggregateValue = DataUtil.PerformAggregation(Orders, aggregates);    //calculate aggregate value using PerformAggregation method 
    } 
} 

[Screenshot] 
 


Please let us know if you have any concerns. 

Regards, 
Rahul  


Marked as answer
Loader.
Up arrow icon