If you became a customer of the Syncfusion� Reporting Platform or the Report Viewer, Report Designer, or Report Writer components before October 2019 and have questions related to those products, you can request support through our forum system. However, please note that this support system is only for existing customers who are still using the Syncfusion� Reporting Platform or its components and not for new customers looking for reporting products from Syncfusion�.

For new customers or those with general reporting questions, we recommend contacting our support team at https://support.boldreports.com/, which is a separate brand created by Syncfusion� for its reporting solutions. Our team will be happy to assist you with any questions you may have.

Thank you for choosing Syncfusion� for your reporting needs.

Change filename of report from ToolBarItem

Hi

I have custom button in toolbar:

public static class SharedReportSettings
{
public static ToolbarSettings ToolbarSettings=> new ToolbarSettings()
{
Items = ToolbarItems.All,
CustomItems = new List<CustomItem>()
{
new CustomItem()
{
GroupIndex = 0,
Index = 1,
CssClass = "e-icon e-pdf-export e-reportviewer-icon",
Type = ToolBarItemType.Default,
Id = "PdfExport",
Tooltip = new ToolTip() { Header = "PDF", Content = "Eksport PDF" }
}
}
};

public static ExportSettings ExportSettings=> new ExportSettings()
{
ExportOptions = ExportOptions.All
& ~ExportOptions.Word
& ~ExportOptions.Html
& ~ExportOptions.CSV

};
}

in this report page:

@page "{id:int?}"
@using Components.Syncfusion
@model WEB.Gala.Pages.Reports.OrderReport

<div class="report-size">
<bold-report-viewer
report-path="OrderReport.rdlc"
id="viewer"
print-mode="true"
toolbar-settings="@SharedReportSettings.ToolbarSettings"
export-settings="@SharedReportSettings.ExportSettings"
tool-bar-item-click="onSharedToolBarItemClick"
report-service-url="/api/ReportViewer"
dataSources="@Model.DataSources"
processing-mode="Local"
print-option="NewTab"
locale="pl-PL"
is-responsive="true">
</bold-report-viewer>
</div>

function onSharedToolBarItemClick(args) {
if (args.value === "PdfExport") {
this.exportReport("Pdf");
}

}


And How can i change filename of report? 

I need to change name of the report depending on some Model values, to generate unique name, something like this:

function onSharedToolBarItemClick(args) {
if (args.value === "PdfExport") {

//HOW TO DO THAT???
//>
this.fileName='@Model.GeneratedName'
//>

this.exportReport("Pdf");
}
}


5 Replies 1 reply marked as answer

MS Muthuramana Sankaranarayanan Syncfusion Team March 19, 2021 09:03 AM UTC

Hi Tomasz, 

We suggest you to refer the below documentation regarding exporting report with specific file name, 


Regards, 
Muthu Ramana S 



TO Tomasz March 19, 2021 11:24 AM UTC

I know the solution you suggested, but unfortunately it doesn't solve my problem. 

In the required business scenario, the report name should be generated based on values in DataSources of the report, and these are set up by the Razor Page model. 

If I did the renaming at the time of the OnInitReportOptions call, then I would have to retrieve the datasources from the report and calculate the name, but i dont want to do that a t this stage, because ReportViewerController will lost flexibility, and it will be very dificult for many reports.

So i need to calculate FileName after binding DataSources to report.




MS Muthuramana Sankaranarayanan Syncfusion Team March 22, 2021 10:16 AM UTC

Hi Tomasz, 

Thanks for explaining your requirement details. 

Your requirement seems to be setting the export file name in client side that is the “RazorPage”. This can be achieved by modifying the name of the file at export item click event. Please refer the below documentation for further details regarding the ‘exportitemclick’ event, 

Please find below example code snippet for changing the export file name, 

<bold-report-viewer id="viewer" ajax-before-load="onAjaxRequest" report-service-url="/api/ReportApi" export-item-click="exportAction"></bold-report-viewer> 

<script type="text/javascript"> 
function exportAction(args) { 
//return your own file name from the Razor Page model 
            args.fileName = "Test123"; 
        } 
</script> 

We have also prepared  a sample meeting your requirement. You can also achieve this in similar manner with your Razor application. Please find the sample from below download link, 

Regards, 
Muthu Ramana S 



TO Tomasz March 22, 2021 10:38 AM UTC

This solution does not solve my problem, because the print to PDF is unfortunately not done through ExportItem, but directly through the added ToolBarItem button. The client would like the export to PDF to not require going into the export menu, but to be available directly as a button in the menu.


MS Muthuramana Sankaranarayanan Syncfusion Team March 23, 2021 07:04 AM UTC

Hi Tomasz, 

We checked your requirement. We suggest you to use the “_processExport(‘PDF’, ‘FileName’)” method in order to achieve your requirement as like shown below. Please find the updated sample from below download link, 
function exportAction(args) { 
        var fileName = "Test123"; 
        var reportviewerObj = $("#viewer").data("boldReportViewer"); 
        reportviewerObj._processExport("PDF", fileName); //Exports the report into PDF format. 
    } 



Regards, 
Muthu Ramana S 


Marked as answer
Loader.
Up arrow icon