BoldReportPartial.cshtml Documentation 📄


Table of Contents

  1. Overview & Purpose
  2. Key Functional Areas
  3. Dependencies & Technologies
  4. View Models & Data Models
  5. Layout & Markup Breakdown
  6. API Endpoints Overview
  7. Event Callbacks & Helper Methods
  8. Error Handling & Return Types
  9. Third‑Party Integrations
  10. UML & Diagrams
  11. Sample Code Blocks
  12. Usage Examples
  13. Conclusion & Best Practices

1. Overview & Purpose 🎯

BoldReportPartial.cshtml is a partial view in the AccountingImaging area of the IrbyImaging project. It embeds the BoldReports web‑based report viewer component to render the LeaseReport.rdl.

  • Intended Use: Display financial or lease-related reports inline, with toolbar support and export functionality.
  • Context: Called from a parent MVC view or controller; requires AngularJS host page to wire up callback handlers.

2. Key Functional Areas 🔑

Area Description
Container DIV Provides a scrollable/minimum-height viewport for the report viewer.
<bold-report-viewer> Tag Custom Angular directive that handles report rendering & interactions.
Report Path Points to LeaseReport.rdl — the RDL definition file on the server.
Service URL /api/ReportViewer – REST endpoint to fetch and process the RDL and its data.
Toolbar Events Hooks for customizing toolbar items and export actions via Angular callbacks.

3. Dependencies & Technologies 🛠️

  • .NET MVC: Razor partial view rendering.
  • AngularJS (1.x): Custom directive bold-report-viewer.
  • BoldReports: Bold’s JavaScript/Angular report rendering library.
  • CSS: Inline styling for width/height — can be overridden by site styles.
  • Backend API: ASP.NET Web API or MVC controller exposing /api/ReportViewer.

4. View Models & Data Models 📦

Note: This partial does not itself declare a view‑model. The data binding and model binding occur inside the Angular directive and the Web API.

  • LeaseReport.rdl
    • RDL file containing layout/data queries.
    • Data sources defined within the report definition.
  • Report Parameters
    • Passed via query-string or API payload (configured in parent view).

5. Layout & Markup Breakdown 🏗️

<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>
Attribute Purpose
id="viewer" Unique DOM identifier for JS/CSS targeting.
report-path LeaseReport.rdl — name of the RDL to load.
report-service-url REST endpoint to fetch/process reports.
toolbar-rendering Angular expression: called before the toolbar is rendered to allow customization.
tool-bar-item-click Angular expression: handles clicks on toolbar items (e.g., print, zoom, refresh).
export-item-click Angular expression: intercept export events (PDF/Excel/Word exports).

6. API Endpoints Overview 🌐

Endpoint Method Description
/api/ReportViewer POST Accepts report path & parameters, returns rendered report stream or JSON for the viewer.
/api/ReportViewer GET (Optional) Fetches parameters or metadata about available reports.

Expected Payload (example):

{
  "reportPath": "LeaseReport.rdl",
  "dataSources": { /* connection details or DS JSON */ },
  "parameters": {
    "LeaseID": 12345
  }
}

7. Event Callbacks & Helper Methods 🔄

The partial wires three Angular callbacks. You must define these in your parent controller:

$scope.onToolbarRendering = function (args) {
  // Customize toolbar items (hide, rename, reorder)
};

$scope.onToolBarItemClick = function (args) {
  // Handle toolbar actions, e.g., refresh or zoom
};

$scope.onExportItemClick = function (args) {
  // Modify export options or intercept exports
};
Callback Arguments Use Case
onToolbarRendering args: ToolbarEventArgs Alter default toolbar before display.
onToolBarItemClick args: MenuEventArgs Custom response to user clicking a toolbar button.
onExportItemClick args: ExportEventArgs Control format/destination of exported document.

8. Error Handling & Return Types ⚠️

  • Client‑side
    • The viewer directive emits error events that can be caught in Angular.
    • Implement $scope.$on('boldReportError', handler) to display UI alerts.
  • Server‑side
    • The Web API should return standard HTTP 4xx/5xx with JSON:
      { "message": "Report not found", "details": "LeaseReport.rdl not deployed." }
      
    • Ensure that exceptions are caught and serialized to a consistent error format.

9. Third‑Party Integrations 🤝

Library / Service Purpose
BoldReports JS/NG Core report rendering engine & UI toolbar.
AngularJS Two‑way data binding and event handling.
RDL (Report Definition Language) Defines layout, data sources, and parameters for reports.

10. UML & Diagrams 📊

10.1 Sequence Diagram

sequenceDiagram
    participant User
    participant Browser
    participant Viewer as BoldReportViewer
    participant API as Report Service (/api/ReportViewer)

    User->>Browser: Navigate to AccountingImaging page
    Browser->>Viewer: Instantiate directive & load LeaseReport.rdl
    Viewer->>API: POST reportPath & parameters
    API-->>Viewer: Return JSON or PDF stream
    Viewer-->>Browser: Render report in UI

10.2 Component Diagram

graph LR
  A[Parent MVC View] --> B[BoldReportPartial.cshtml]
  B --> C[bold-report-viewer Directive]
  C --> D[/api/ReportViewer Endpoint]
  D --> E[LeaseReport.rdl & DataSources]

11. Sample Code Blocks 📋

11.1 Parent View Integration

@* In AccountingImagingController.cs *@
public ActionResult ViewLeaseReport(int leaseId) {
    ViewBag.LeaseId = leaseId;
    return PartialView("BoldReportPartial");
}
@* In parent Razor view *@
<div ng-controller="LeaseReportController">
  @Html.Partial("BoldReportPartial")
</div>

11.2 AngularJS Controller Snippet

app.controller('LeaseReportController', ['$scope', function($scope) {
  $scope.onToolbarRendering = function(args) {
    // Example: hide the print button
    args.toolbarItems = args.toolbarItems.filter(item => item.id !== 'print');
  };

  $scope.onToolBarItemClick = function(args) {
    console.log('Clicked:', args.id);
  };

  $scope.onExportItemClick = function(args) {
    if (args.format === 'Pdf') {
      alert('Exporting to PDF...');
    }
  };
}]);

12. Usage Examples 🖥️

  1. Basic: Just embed the partial and define callbacks:
    <div ng-controller="ReportCtrl">
      @Html.Partial("BoldReportPartial")
    </div>
    
  2. Parameter Passing: Pass LeaseID as a query param in the parent view, and configure the Web API to inject into RDL:
    // Extend the directive tag:
    <bold-report-viewer
       report-path="LeaseReport.rdl?LeaseID={{LeaseId}}"
       …></bold-report-viewer>
    

13. Conclusion & Best Practices 🏁

  • Modularity
    Keep this partial view lightweight; heavy logic belongs in controllers/services.
  • Styling
    Override inline CSS via your site’s main stylesheet for responsive layouts.
  • Security
    Validate report parameters server‑side to prevent injection.
  • Error Feedback
    Surface server errors gracefully in the UI using Angular events.
  • Performance
    Cache RDL files on the server and reuse data‑source connections for faster load times.

🎉 You’re all set! Embed, customize callbacks, and deliver rich, interactive Lease reports using BoldReports in your AccountingImaging module.