📋 Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- Key Functional Areas
BoldReportPartial.cshtmlDeep Dive
4.1. File Location & Naming
4.2. Full Code Listing
4.3. Attribute Reference Table
4.4. Event Handlers Overview- API Endpoints Overview
- Sample Backend Implementation (C# .NET Core)
- Usage Examples
- UML Diagrams
- Conclusion
🎯 Overview & Purpose
BoldReportPartial.cshtml is a Razor partial view used to embed a Bold Reports Viewer into an ASP.NET (or ASP.NET Core) application. It:
- Renders an interactive report viewer in the browser
- Loads an RDL report file (
LeaseReport.rdl) - Hooks into toolbar and export events for customization
- Communicates with a backend API (
/api/ReportViewer) to fetch or export reports
This partial enables the Legal Imaging module to display lease reports dynamically, with built‑in pagination, export options (PDF, Excel, Word, etc.), and customizable toolbar buttons.
⚙️ Dependencies & Technologies
| Technology | Purpose |
|---|---|
| ASP.NET / Razor | Server‐side view rendering |
| Bold Reports Viewer | JavaScript report control |
| RDL (Report Definition Language) | Report definition file format |
| C# (.NET Core) | Backend API implementation |
| jQuery / AngularJS | (Optional) for wiring client events |
Third‑Party Integration:
- Bold Reports JavaScript SDK
- Bold Reports REST API
🔑 Key Functional Areas
-
HTML Container
Ensures the report viewer has sufficient space (min-height:800px). -
<bold-report-viewer>- Loads and renders the RDL file
- Provides toolbar UI and export functionality
- Exposes event hooks to customize behavior
-
Event Bindings
toolbar-rendering→ Customize toolbar itemstool-bar-item-click→ Handle toolbar button clicksexport-item-click→ Intercept export requests
-
API Communication
Calls/api/ReportViewerto fetch report pages or perform exports.
🛠 BoldReportPartial.cshtml Deep Dive
4.1 File Location & Naming
IrbyImaging/
└─ Views/
└─ LegalImaging/
└─ BoldReportPartial.cshtml
Naming Convention:
Partialsuffix indicates this is meant to be included in other views, not a standalone page.
4.2 Full Code Listing
<div style="min-height: 800px; width: 100%;">
<bold-report-viewer
id="viewer"
report-path="LeaseReport.rdl"
report-service-url="/api/ReportViewer"
toolbar-rendering="onToolbarRendering"
tool-bar-item-click="onToolBarItemClick"
export-item-click="onExportItemClick">
</bold-report-viewer>
</div>
4.3 Attribute Reference Table
| Attribute | Description | Example Value |
|---|---|---|
| id | Unique DOM identifier for the viewer instance. | viewer |
| report-path | Relative path (or name) of the .rdl report to load. |
LeaseReport.rdl |
| report-service-url | Backend API endpoint that Bold Reports calls for data retrieval & export. | /api/ReportViewer |
| toolbar-rendering | Client‑side event invoked before toolbar renders. Allows adding/removing toolbar buttons. | onToolbarRendering |
| tool-bar-item-click | Fired when a user clicks any toolbar item. | onToolBarItemClick |
| export-item-click | Fired when the export button/menu is used. Can override default export behavior. | onExportItemClick |
4.4 Event Handlers Overview
| Event | Purpose | Sample JS Handler |
|---|---|---|
onToolbarRendering |
Customize/add/remove toolbar items dynamically. | see code snippet below |
onToolBarItemClick |
Respond to built‑in toolbar button clicks. | e.g., open modal, log analytics |
onExportItemClick |
Validate or override export parameters before sending. | e.g., prompt user for file options |
<script>
function onToolbarRendering(args) {
// 🎨 Add a custom button
args.toolbarItems.push({
type: 'Button',
text: '🔍 Zoom to Fit',
id: 'zoomToFit',
click: function() { /* zoom logic */ }
});
}
function onToolBarItemClick(args) {
console.log('Toolbar clicked:', args.item.id);
// e.g., if (args.item.id === 'zoomToFit') { … }
}
function onExportItemClick(args) {
// Cancel default export
args.cancel = true;
// Custom export flow
customExport(args.format);
}
</script>
🔄 API Endpoints Overview
Endpoint: /api/ReportViewer
Purpose:
- Fetch report pages
- Export reports (PDF, Excel, Word, etc.)
- Pass through to Bold Reports server engine
| HTTP Method | URL | Description | Request Body | Response |
|---|---|---|---|---|
| POST | /api/ReportViewer |
Main entry point for viewer operations | JSON (report name, export format, parameters) | JSON or binary stream |
| GET | /api/ReportViewer |
(Optional) Retrieve metadata or status | Query string | JSON metadata |
🔧 Sample Backend Implementation (C# .NET Core)
[ApiController]
[Route("api/[controller]")]
public class ReportViewerController : ControllerBase
{
private readonly IReportEngine _reportEngine;
public ReportViewerController(IReportEngine reportEngine)
{
_reportEngine = reportEngine;
}
[HttpPost]
public IActionResult Post([FromBody] ViewerRequest model)
{
// 1. Load the RDL
var report = _reportEngine.LoadReport($"Reports/{model.ReportPath}");
// 2. If export
if (model.Action == "Export")
{
var bytes = _reportEngine.Export(report, model.Format, model.Parameters);
return File(bytes, GetMimeType(model.Format), $"{model.ReportName}.{model.Format.ToLower()}");
}
// 3. Otherwise, render page
var pageData = _reportEngine.RenderPage(report, model.PageNumber);
return Ok(pageData);
}
private string GetMimeType(string format) => format switch {
"PDF" => "application/pdf",
"EXCEL" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
_ => "application/octet-stream"
};
}
public class ViewerRequest {
public string ReportPath { get; set; }
public string Action { get; set; } // e.g., "Render", "Export"
public string Format { get; set; } // e.g., "PDF", "EXCEL"
public int PageNumber { get; set; }
public IDictionary<string, object> Parameters { get; set; }
}
👀 Usage Examples
1. Render Partial in a Parent View
@{
ViewData["Title"] = "Lease Report Viewer";
}
<h2>@ViewData["Title"]</h2>
@Html.Partial("~/Views/LegalImaging/BoldReportPartial.cshtml")
2. Custom JavaScript Hookup
@section Scripts {
<script src="~/lib/boldreports/webcomponent.min.js"></script>
<script>
// Already shown above: onToolbarRendering, onToolBarItemClick, onExportItemClick
</script>
}
📈 UML Diagrams
1. Sequence Diagram
sequenceDiagram
participant U as User
participant V as BoldReportViewer
participant A as Browser JS
participant API as /api/ReportViewer
participant B as Bold Reports Engine
U->>V: Click “Export”
V->>A: fire export-item-click
A->>API: HTTP POST {Action:"Export", Format:"PDF", ReportPath:"LeaseReport.rdl"}
API->>B: Process RDL → Generate PDF
B->>API: byte[]
API->>A: PDF byte stream
A->>U: Download prompt
2. Component Diagram
classDiagram
class BoldReportPartial {
+string reportPath
+string reportServiceUrl
+event toolbarRendering
+event toolBarItemClick
+event exportItemClick
}
class ReportViewerController {
+Post(ViewerRequest)
-LoadReport(string)
-RenderPage(...)
-Export(...)
}
BoldReportPartial ..> ReportViewerController : calls
ReportViewerController ..> BoldReports.Engine : processes
🏁 Conclusion
BoldReportPartial.cshtml is the cornerstone for embedding rich, interactive lease-reporting capabilities into the Legal Imaging module. By combining the Bold Reports Viewer component with a lightweight ASP.NET API, you gain:
- ✅ Rapid rendering of RDL files in the browser
- ✅ Full control over toolbar & export workflows
- ✅ Easy integration with existing MVC views
- ✅ Extensibility via JavaScript event hooks
Leverage this partial in your pages, customize the toolbar and export logic to match your business needs, and provide end‑users with a polished, powerful reporting experience! 🚀