📝 MunicipalLicenseReport.cshtml Documentation

Path: IrbyImaging/Views/AccountingImaging/MunicipalLicenseReport.cshtml


📚 Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. View Model & Data Models
  4. Key Functional Areas
    4.1. Layout & Title
    4.2. Custom Styles (CSS)
    4.3. HTML Structure & Syncfusion Grid
    4.4. Toolbar & Buttons
    4.5. Client-Side Scripts & Events
  5. Helper Methods & Utilities
  6. Error Handling & Return Types
  7. API Endpoints Overview
  8. Third‑party Integrations
  9. Sample Code Blocks & Usage Examples
  10. UML Class Diagram
  11. Conclusion

1. Overview & Purpose

The MunicipalLicenseReport.cshtml view renders a Municipal/County License Report grid using the Syncfusion EJ2 Grid component. It displays a list of license records—such as state, license number, classifications, issuing party, and expiration—allowing the user to:

  • Sort, filter, group, and paginate through data
  • Perform Excel exports and live searches
  • Edit, add, or delete records directly (inline editing)

This view is part of the AccountingImaging module of the IrbyImaging application and is designed for administrative or audit use-cases where municipal license data must be reviewed or maintained.


2. Dependencies & Technologies

Technology / Library Version (Approx.) Description
ASP.NET Core MVC (Razor) ≥ 2.0 Server‑side templating engine
Syncfusion EJ2 JavaScript Latest Rich client‑side grid, buttons, export utility
jQuery (optional) — DOM querying/manipulation
CSS — Custom styling for grid elements
PlantUML (for documentation) — UML diagram generation

☑️ NuGet Packages & Imports

@using Syncfusion.JavaScript
@using Syncfusion.JavaScript.Models
@using Syncfusion.EJ2

3. View Model & Data Models

@model IrbyImaging.DomainClasses.LicenseReport
  • LicenseReport is the domain class representing a single license entry:
    • string State
    • string LicenseNumber
    • string LicenseClassifications
    • string ClassificationCodes
    • string IssuingParty
    • DateTime DateAcquired
    • string Status
    • DateTime ExpirationDate
    • string RenewalStatus
    • string Qualifiers

Data Source Binding:
Data is supplied via ViewBag.datasource – typically a List<LicenseReport> passed from the controller.


4. Key Functional Areas

4.1. Layout & Title

@{
  ViewData["Title"] = "List";
  // Layout can be switched if needed:
  // Layout = "~/Views/Shared/_LegalLayout.cshtml";
}
<h2>Municipal/County Licenses</h2>
  • ViewData["Title"] sets the HTML <title>.
  • The <h2> header displays the page title.

4.2. Custom Styles (CSS)

<style>
  .e-grid .e-gridheader { border: 2px solid black; }
  .e-grid .e-headercell { color: darkblue; }
  .e-grid .e-sortnumber { background-color: #deecf9; font-family: cursive; }
  /* ...more customizations for icons, grouping, indent cells, etc. */
</style>
  • Objective:
    Enhance readability with borders, colors, and typography for different grid states (sorted, grouped, expanded).

4.3. HTML Structure & Syncfusion Grid

<ejs-grid
  id="Grid"
  gridLines="Both"
  allowSorting="true"
  allowGrouping="true"
  allowFiltering="true"
  allowRowDragAndDrop="true"
  allowPaging="true"
  allowTextWrap="true"
  dataSource="@ViewBag.datasource"
  toolbar="@(new List<string>{"ExcelExport","Search"})"
  toolbarClick="toolbarClick"
  allowExcelExport="true">
  
  <e-grid-filterSettings type="Excel"></e-grid-filterSettings>
  <e-grid-editSettings allowAdding="true" allowEditing="true" allowDeleting="true" edit-mode="Normal"></e-grid-editSettings>
  
  <e-grid-columns>
    <e-grid-column field="State" headerText="STATE" textAlign="Left" isPrimaryKey="true"></e-grid-column>
    <!-- Other columns omitted for brevity… -->
    <e-grid-column field="Qualifiers" headerText="QUALIFIER(S)" textAlign="Left"></e-grid-column>
  </e-grid-columns>
</ejs-grid>
  • Key Features:
    • Filtering: Excel‑style (<e-grid-filterSettings type="Excel"/>)
    • Editing: Inline add/edit/delete
    • Export: Excel export via toolbar
    • Search: Built‑in search box
    • Grouping & Sorting: Drag column headers

4.4. Toolbar & Buttons

<ejs-button id="clear" content="Clear Search"></ejs-button>
  • Clear Search button resets the current search filters.

4.5. Client-Side Scripts & Events

<script>
  // Clear search input
  document.getElementById('clear').addEventListener('click', () => {
    var gridObj = document.getElementById("Grid").ej2_instances[0];
    gridObj.searchSettings.key = '';
  });

  // Handle toolbar actions (e.g., ExcelExport)
  function toolbarClick(args) {
    var gridObj = document.getElementById("Grid").ej2_instances[0];
    if (args.item.id === 'Grid_excelexport') {
      gridObj.excelExport();
    }
  }
</script>
  • clear Click Handler: Resets the searchSettings.key to an empty string → clears search.
  • toolbarClick Function: Triggers excelExport() when the Excel icon is clicked.

5. Helper Methods & Utilities

Method Name Location Purpose
toolbarClick(args) Inline <script> Exports grid data to Excel when toolbar button clicked.
Anonymous Inline <script> Clears the search key to reset filtering.

Note: Extendable for more toolbar items (PDF export, CSV, etc.).


6. Error Handling & Return Types

  • Error Handling:

    • Currently minimal → relies on Syncfusion’s built-in error handling.
    • For production scenarios, wrap AJAX calls/error events to show user-friendly messages.
  • Return Types:

    • Server → ViewResult with model/data in ViewBag.datasource.
    • Client → void (UI actions).

7. API Endpoints Overview

None in this view.
All data is pre-fetched and bound using Razor's ViewBag.
To integrate real-time data, consider adding WebAPI endpoints:

[HttpGet]
public IActionResult GetLicenseReports() {
  var data = _licenseService.GetAll();
  return Json(data);
}

8. Third‑party Integrations

  • Syncfusion EJ2
    • Grid: Filtering, Sorting, Grouping, Editing, Export
    • Button: Clear Search
    • Must have proper Syncfusion scripts & styles referenced in _Layout.cshtml.

9. Sample Code Blocks & Usage Examples

9.1. Controller Sample

public class AccountingImagingController : Controller {
  public IActionResult MunicipalLicenseReport() {
    var licenses = _licenseReportService.GetAll(); // List<LicenseReport>
    ViewBag.datasource = licenses;
    return View();
  }
}

9.2. Passing Data to View

// In Startup.cs
services.AddScoped<ILicenseReportService, LicenseReportService>();

// LicenseReportService returns List<LicenseReport>

9.3. Calling Excel Export

  1. Click ExcelExport icon in toolbar
  2. toolbarClick triggers gridObj.excelExport()
  3. Browser downloads .xlsx file

10. UML Class Diagram

@startuml
class LicenseReport {
  +string State
  +string LicenseNumber
  +string LicenseClassifications
  +string ClassificationCodes
  +string IssuingParty
  +DateTime DateAcquired
  +string Status
  +DateTime ExpirationDate
  +string RenewalStatus
  +string Qualifiers
}

class MunicipalLicenseReportView {
  +ejsGrid: Syncfusion.EJ2.Grid
  +clearButton: Syncfusion.EJ2.Button
  +toolbarClick()
  +clearSearch()
}

LicenseReport <.. MunicipalLicenseReportView : uses
@enduml

Render this via a PlantUML viewer to visualize the relationship.


11. Conclusion

MunicipalLicenseReport.cshtml is a rich, interactive Razor view tailored to display and manage municipal license data. Leveraging Syncfusion EJ2, it provides:

  • Full CRUD capability (adding/editing/deleting)
  • Advanced filtering & sorting
  • Excel export & live search

This documentation detailed its structure, usages, and customization points. To extend its functionality, you may:

  • Integrate RESTful APIs for dynamic data-loading
  • Implement additional toolbar options (PDF, CSV)
  • Add modal dialogs for advanced editing

💡 Next Steps:

  1. Ensure Syncfusion scripts & styles are registered.
  2. Implement server-side validation & error messages.
  3. Enhance accessibility (ARIA labels, keyboard navigation).

End of documentation 🚀