π BoldReport.cshtml Documentation
π Table of Contents
- Overview & Purpose
- File Location & Layout Integration
- Key Functional Areas
- Dependencies & Technologies
- Component Configuration
- Attribute Bindings & View Data
- Event Handlers
- API Endpoints Overview
- Sample Usage & Code Snippets
- UML Diagram
- Conclusion
1. Overview & Purpose
BoldReport.cshtml is a Razor View in the AccountingImaging module of the IrbyImaging project. It serves as a wrapper page to host the Bold Reports web report viewer component and provides users with a dynamic, interactive reporting interface.
- π― Primary Goals
- Render a report viewer using Bold Reports web component
- Dynamically load different report definitions based on
ViewBag.ReportType - Provide toolbar actions such as print, export, zoom, etc.
2. File Location & Layout Integration
Path:
IrbyImaging/
βββ Views/
βββ AccountingImaging/
βββ BoldReport.cshtml
Layout
@{ Layout = "~/Views/Shared/_reportLayout.cshtml"; }
- Uses a shared layout (
_reportLayout.cshtml) which typically includes:- Global CSS/JS references
- Header, footer, navigation elements
- Scripts to bootstrap Angular/JavaScript for Bold Reports
3. Key Functional Areas
| Section | Description |
|---|---|
<div> Container |
Ensures minimum height & responsive width for the viewer. |
<bold-report-viewer> |
Custom web component for Bold Reports. |
| Attribute Bindings | Controls the report path, service URL, and event callbacks. |
4. Dependencies & Technologies
| Technology / Library | Purpose |
|---|---|
| ASP.NET MVC / Razor | Server-side view rendering |
| Bold Reports Web Viewer | Front-end report rendering & toolbar UI |
| Angular / JavaScript | Event handling & component lifecycle |
| CSS (inline or external) | Layout and sizing |
5. Component Configuration
<div style="min-height: 800px; width: 100%;">
<bold-report-viewer
id="viewer"
report-path="@ViewBag.ReportType"
report-service-url="/api/ReportViewer"
toolbar-rendering="onToolbarRendering"
tool-bar-item-click="onToolBarItemClick"
export-item-click="onExportItemClick">
</bold-report-viewer>
</div>
-
Container
<div>min-height: 800pxensures adequate space for report content.width: 100%makes the viewer responsive.
-
<bold-report-viewer>AttributesAttribute Type Description idstring DOM identifier ( viewer)report-pathstring Path or key of the report ( ViewBag.ReportType)report-service-urlstring Backend API route to fetch report data ( /api/ReportViewer)toolbar-renderingcallback JS function invoked when toolbar is initialized tool-bar-item-clickcallback JS callback for toolbar button clicks (e.g., print, refresh) export-item-clickcallback JS callback for export operations (e.g., PDF, Excel)
6. Attribute Bindings & View Data
- ViewBag.ReportType
- Passed from the Controller
- Example values:
"SalesSummary","InvoiceDetails", etc.
- Accessing in View
report-path="@ViewBag.ReportType" - Controller Snippet
public ActionResult BoldReport(string reportType) { ViewBag.ReportType = reportType; return View(); }
7. Event Handlers
These JavaScript functions should be defined in the shared layout or included scripts:
function onToolbarRendering(args) {
// Customize toolbar items (enable/disable buttons)
}
function onToolBarItemClick(args) {
// Handle click events: print, refresh, zoom, etc.
console.log("Toolbar item clicked:", args.itemName);
}
function onExportItemClick(args) {
// Customize export settings: PDF, Excel, CSV
console.log("Exporting report as:", args.format);
}
- π§ Customization Points
- Enable/disable specific toolbar items
- Prompt user dialogs (e.g. export options)
- Track analytics on toolbar usage
8. API Endpoints Overview
| Endpoint | Method | Description |
|---|---|---|
/api/ReportViewer |
POST | Returns report data JSON or binary streams. |
Typical Request Payload
{
"reportPath": "SalesSummary",
"dataSource": { /* parameters */ }
}
Typical Response
- JSON containing report definition & data
- Binary stream for direct viewer consumption
9. Sample Usage & Code Snippets
9.1 Controller Action
public class AccountingImagingController : Controller
{
public ActionResult BoldReport(string reportType = "DefaultReport")
{
ViewBag.ReportType = reportType;
return View();
}
}
9.2 Calling the View
<a href="@Url.Action("BoldReport", "AccountingImaging", new { reportType = "InvoiceDetails" })">
π View Invoice Details Report
</a>
9.3 Including Scripts in _reportLayout.cshtml
<!-- Bold Reports Core & Viewer Scripts -->
<script src="~/lib/boldreports/js/bold.reports.min.js"></script>
<script src="~/lib/boldreports/js/bold.report-viewer.min.js"></script>
<!-- Custom Event Handlers -->
<script src="~/js/report-viewer-handlers.js"></script>
10. UML Diagram
classDiagram
class BoldReportView
BoldReportView : +string reportPath
BoldReportView : +string reportServiceUrl
BoldReportView : +onToolbarRendering()
BoldReportView : +onToolBarItemClick()
BoldReportView : +onExportItemClick()
class ReportApi
ReportApi : +POST /api/ReportViewer()
BoldReportView --> ReportApi : fetchReport()
BoldReportView ..> _reportLayout : uses
11. Conclusion
BoldReport.cshtml is a lightweight Razor view designed to seamlessly integrate the Bold Reports web viewer into the Accounting Imaging module. By binding a dynamic @ViewBag.ReportType and wiring up event callbacks, it delivers a flexible, interactive reporting experience without embedding complex logic into the view itself.
β¨ Key Takeaways
- Leverages shared layout for consistent look & feel
- Minimal markupβdelegates rendering & events to Bold Reports component
- Fully extensible via JS callbacks and convenient API endpoint
Ready to plug in any report and get powerhouse visualizations in seconds! π
Happy Reporting! π