I want to display Sub TotalAmount instead of SUM

I want to display the word Sub TotalAmount instead of SumScreenshot (376)_LI.jpg


3 Replies

DM Dhivyabharathi Mohan Syncfusion Team November 22, 2021 05:46 PM UTC

Hi Belle, 
 
Thank you for contacting Syncfusion support. 
 
Before we validate and proceed further, we would like to know the below details as we are not clear with the provided information.  
  1. Please confirm if you are trying to export from DataGrid to PDF. If no, kindly share the Syncfusion Component detail from which you are exporting to PDF
  2. Also, share the Syncfusion package details with the version.
This will be helpful to investigate further and provide the solution at the earliest. 
 
Regards, 
Dhivya. 



AG Ashley Grey November 23, 2021 05:12 AM UTC

Good afternoon. I am trying to export Datagrid to PDF. and when exported I want to display the Sub TotalAmount instead of Sum.




VN Vignesh Natarajan Syncfusion Team November 24, 2021 07:55 AM UTC

Hi Belle,  
 
Thanks for the confirmation.  
 
Query: “I am trying to export Datagrid to PDF. and when exported I want to display the Sub TotalAmount instead of Sum. 
 
We have validated query your requirement and we suggest you to achieve your requirement using PdfAggregateTemplateInfo event of Grid. This event will be triggered when aggregate data value is exported to pdf cell. Here we suggest you to change the cell value to prefix “TotalAmount”.  
 
Refer the below code example. 
 
<SfGrid ID="Grid" @ref="DefaultGrid" DataSource="@Orders" AllowGrouping="true" Toolbar="@(new List<string>() { "PdfExport" })" AllowPdfExport="true"> 
    <GridGroupSettings Columns="@Initial"></GridGroupSettings> 
    <GridEvents OnToolbarClick="ToolbarClickHandler" PdfAggregateTemplateInfo="AggregateTemplate" TValue="Order"></GridEvents> 
    <GridAggregates> 
        <GridAggregate> 
            <GridAggregateColumns> 
                <GridAggregateColumn Field=@nameof(Order.Freight) Type="AggregateType.Sum" Format="N2"> 
                    <GroupCaptionTemplate> 
                        @{ 
                            var aggregate = (context as AggregateTemplateContext); 
                            <div> 
                                <p>TotalAmount: @aggregate.Sum</p> 
                            </div> 
                        } 
                    </GroupCaptionTemplate> 
                </GridAggregateColumn> 
            </GridAggregateColumns> 
        </GridAggregate> 
    </GridAggregates> 
    <GridColumns> 
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn> 
        <GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn> 
        <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
    </GridColumns> 
</SfGrid> 
  
@code{ 
    private SfGrid<Order> DefaultGrid; 
    public List<Order> Orders { getset; } 
  
    public void AggregateTemplate(PdfAggregateEventArgs Args) 
    { 
        if (Args.Column.Field == "Freight") 
        { 
            Args.Cell.Value = "TotalAmount: "+ Args.Cell.Value; 
        } 
    } 
    public async Task ToolbarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args) 
    { 
        if (args.Item.Id == "Grid_pdfexport")  //Id is combination of Grid's ID and itemname 
        { 
            await this.DefaultGrid.PdfExport(); 
        } 
    } 
 
 
Kindly refer the below sample for your reference 
 
 
Refer our UG documentation for your reference 
 
 
Please get back to us if you have further queries.  
 
Regards, 
Vignesh Natarajan 


Loader.
Up arrow icon