How to Customize Save and Open Buttons in Bold Reports Report Designer
To customize the Save and Open buttons in the Bold Reports .NET Core Report Designer, either hide the built-in buttons through toolbar settings and add your own buttons or override the built-in actions with the save-report-click and open-report-click events. Both approaches let you save and open reports from a custom location.
Steps
You can customize the buttons in two ways. Choose one.
Method 1: Hide the built-in buttons and add custom buttons
-
Hide the Save and Open toolbar items. In .NET Core, set the toolbar items with a
ViewBagvalue in the controller and remove Save and Open with a bitwise mask.public IActionResult Index() { ViewBag.toolbarSettings = new BoldReports.Models.ReportDesigner.ToolbarSettings(); ViewBag.toolbarSettings.Items = BoldReports.ReportDesignerEnums.ToolbarItems.All & ~BoldReports.ReportDesignerEnums.ToolbarItems.Save & ~BoldReports.ReportDesignerEnums.ToolbarItems.Open; return View(); } -
Bind the toolbar settings to the designer and add your own Open and Save buttons in the view.
<button id="Open" type="button" value="Open">Open</button> <button id="Save" type="button" value="Save">Save</button> <div style="height: 600px; width: 100%;"> <bold-report-designer id="reportdesigner1" create="controlInitialized" service-url="../Home" report-data-extensions="@ViewBag.ReportDataExtensions" toolbar-settings="@ViewBag.toolbarSettings" ajax-before-load="ajaxBeforeLoad" report-saved="reportSaved" report-opened="reportOpened" toolbar-click="toolbarClick" report-modified="reportModified"> </bold-report-designer> </div> -
Wire your buttons to the designer API so they open and save the report from your custom location. Each handler reads the designer instance before calling an API method, so the instance is always available.
$("#Open").click(function (e) { var designer = $('#reportdesigner1').data('boldReportDesigner'); // Set these from your own application. The server path format is "/<category>/<reportName>". var category = "Sample Reports"; var reportName = "Sales Report"; designer.openReport("/" + category + "/" + reportName); }); $("#Save").click(function (e) { var designer = $('#reportdesigner1').data('boldReportDesigner'); if (!designer.isNewServerReport()) { // Existing report: save it back to the same server path. designer.saveReport(); } else { // New report: save it to a specific server path. // Path format is "/<category>/<reportName>"; isOverWrite = false creates a new report. designer.saveReport("/Sample Reports/Sales Report", false); } });
Method 2: Override the built-in button actions
-
Keep the built-in buttons visible but handle their actions yourself. Bind the
save-report-clickandopen-report-clickevents on the designer.<div style="height: 600px; width: 100%;"> <bold-report-designer id="reportdesigner1" create="controlInitialized" service-url="../Home" report-data-extensions="@ViewBag.ReportDataExtensions" save-report-click="saveMenuClick" open-report-click="openMenuClick" ajax-before-load="ajaxBeforeLoad" report-saved="reportSaved" report-opened="reportOpened" toolbar-click="toolbarClick" report-modified="reportModified"> </bold-report-designer> </div> -
In each handler, read the designer instance, check
args.selectto find which menu option was chosen, call the matching designer method, and setargs.cancel = trueto stop the default action. Every method below is part of the Report Designer JavaScript API.function openMenuClick(args) { var designer = $('#reportdesigner1').data('boldReportDesigner'); switch (args.select) { case 'Device': // Open the report from the user's device. designer.openReportFromDevice(); args.cancel = true; break; case 'Server': // Open the report from the report server. designer.openServerReportDialog(); args.cancel = true; break; } } function saveMenuClick(args) { var designer = $('#reportdesigner1').data('boldReportDesigner'); switch (args.select) { case 'Save': // Save the current report back to the server. designer.saveReport(); args.cancel = true; break; case 'SaveAsDisk': // Download the report file to the device. designer.saveToDevice(); args.cancel = true; break; case 'SaveAsServer': // Open the save-to-server dialog to choose a category and name. designer.saveServerReportDialog(); args.cancel = true; break; } }
Result
With Method 1, the default Save and Open buttons no longer appear, and your custom buttons save and open reports from the location you specify. With Method 2, the built-in buttons stay in place but run your handlers instead of the default actions.