📄 Documentation: ECLicenseReport.cshtml

Path: IrbyImaging/Views/LegalImaging/ECLicenseReport.cshtml


📑 Table of Contents

  1. Overview & Purpose
  2. Key Functional Areas
  3. Dependencies & Technologies
  4. View Model & Data Model
  5. Helper Methods & Utilities
  6. Error Handling & Return Types
  7. API Endpoints Overview
  8. Third‑party Integrations
  9. Sample Code Snippets & Usage Examples
  10. UML Diagram
  11. Conclusion & Next Steps

1. 📖 Overview & Purpose

This Razor View renders a rich, interactive Syncfusion EJ2 Grid to display a report of Electrical Contractor Licenses.
It is designed for the Legal Imaging feature in the IrbyImaging application, enabling users to:

  • 🔍 Search, filter, group, and sort license records
  • 📄 Export the grid data to Excel
  • 🛠️ Perform CRUD operations (add, edit, delete) on license entries

2. 🔑 Key Functional Areas

2.1 Layout & Metadata

@model IrbyImaging.DomainClasses.LicenseReport
@using Syncfusion.JavaScript
@using Syncfusion.JavaScript.Models
@using Syncfusion.EJ2

@{
    ViewData["Title"] = "List";
    Layout = "~/Views/Shared/_LegalLayout.cshtml";
}
  • Model Binding: Binds to LicenseReport domain model.
  • Title: Page title set to "List".
  • Layout: Inherits from the shared _LegalLayout.cshtml for consistent look & feel.

2.2 Styling & CSS Overrides

Custom styles to tweak the Syncfusion Grid’s appearance:

<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; }
.e-grid .e-groupcaption { background-color: #add8e6; font-style: italic; }
.e-grid .e-recordplusexpand { background-color: #5968bf; }
.e-grid .e-indentcell { background-color: lightblue; }
</style>
Class Purpose
.e-gridheader Thick black border around headers
.e-headercell Dark blue header text
.e-sortnumber Special styling for row number column
.e-groupcaption Light‑blue italic background for groups
.e-recordplusexpand Dark expand button for grouped rows

2.3 Grid Configuration

<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="@(EditMode.Normal)">
  </e-grid-editSettings>
  
  <!-- Columns Defined Below -->
</ejs-grid>
  • Data Source: Supplied via ViewBag.datasource (e.g., List<LicenseReport>).
  • Features Enabled: Sorting, grouping, filtering (Excel style), drag‑and‑drop, paging, text wrap.
  • Toolbar:
    • ExcelExport – export to .xlsx
    • Search – global search textbox

2.4 Columns & Data Binding

Field Header Text Alignment Primary Key
State STATE Left ✔
LicenseNumber LICENSE NUMBER — ✔
LicenseClassifications LICENSE CLASSIFICATION(S) Left ✔
ClassificationCodes CLASSIFICATION CODE(S) Center —
IssuingParty ISSUED BY Left —
DateAcquired ACQUIRED ON Left —
Status STATUS Left —
ExpirationDate EXPIRES ON Left —
RenewalStatus RENEWAL STATUS Left —
Qualifiers QUALIFIER(S) Left —
<e-grid-columns>
  <e-grid-column field="State" headerText="STATE" textAlign="Left" isPrimaryKey="true"></e-grid-column>
  <!-- ... other columns ... -->
</e-grid-columns>

2.5 Toolbar & Excel Export

  • Clear Search button:

    <ejs-button id="clear" content="Clear Search"></ejs-button>
    
  • Toolbar Click Handler (toolbarClick):

    function toolbarClick(args) {
      var gridObj = document.getElementById("Grid").ej2_instances[0];
      if (args.item.id === 'Grid_excelexport') {
        gridObj.excelExport();
      }
    }
    

2.6 Custom Scripts & Event Handlers

<script>
  // Clear search textbox
  document.getElementById('clear').addEventListener('click', () => {
    var gridObj = document.getElementById("Grid").ej2_instances[0];
    gridObj.searchSettings.key = '';
  });
  
  // Export to Excel on toolbar click (see above)
</script>

3. 🛠️ Dependencies & Technologies

Technology / Library Purpose
ASP.NET Core MVC / Razor Server‑side rendering & view engine
Syncfusion EJ2 Grid Interactive data grid component
Syncfusion.JavaScript Core JS for Syncfusion components
Syncfusion.JavaScript.Models Model definitions for Syncfusion

4. 🧩 View Model & Data Model

public class LicenseReport {
    public string State { get; set; }
    public string LicenseNumber { get; set; }
    public string LicenseClassifications { get; set; }
    public string ClassificationCodes { get; set; }
    public string IssuingParty { get; set; }
    public DateTime DateAcquired { get; set; }
    public string Status { get; set; }
    public DateTime ExpirationDate { get; set; }
    public string RenewalStatus { get; set; }
    public string Qualifiers { get; set; }
}
  • Primary Keys: State, LicenseNumber, LicenseClassifications (composite key to ensure unique rows).

5. 🗂️ Helper Methods & Utilities

  • toolbarClick(args)
    Handles toolbar button clicks (Excel export).
  • Clear Search Listener
    Resets the grid’s search textbox when "Clear Search" is clicked.

6. 🐞 Error Handling & Return Types

  • View‑level: No explicit error handling in this view.
  • Server‑side: The controller action must supply ViewBag.datasource.
  • Grid Validation: Syncfusion’s built‑in validation for edit settings applies.

7. 🌐 API Endpoints Overview

Note: This view does not call any REST APIs directly; it relies on server‑side data passed via ViewBag.
For AJAX binding or remote data, you could plug in:

<ejs-grid dataSource="https://api.irbyimaging.com/licenses"></ejs-grid>

8. 🔌 Third‑party Integrations

  • Syncfusion EJ2 for grid, filtering, grouping, paging, and Excel export.
  • Bootstrap 4/5 (via shared _LegalLayout) for responsive layout (row & col-12).

9. 📋 Sample Code Snippets & Usage Examples

A. Adding a New Column

<e-grid-column field="AgentName"
               headerText="AGENT"
               textAlign="Left">
</e-grid-column>

B. Custom Date Formatting

<e-grid-column field="ExpirationDate"
               headerText="EXPIRES ON"
               type="date"
               format="yMd">
</e-grid-column>

C. Remote Data Binding (AJAX)

<ejs-grid id="Grid"
          dataSource-url="https://api.irbyimaging.com/licenses"
          dataSource-adapter="UrlAdaptor">
</ejs-grid>

10. 📈 UML Diagram

classDiagram
    LicenseReport --> SyncfusionGrid
    SyncfusionGrid --> ExcelExport
    Controller  --> LicenseReport
    Controller  --> View (ECLicenseReport.cshtml)
    View        --> Syncfusion.Javascript

11. 🏁 Conclusion & Next Steps

  • Customization: You can easily add/remove columns, change filtering modes, or hook into JS events (rowSelected, actionComplete, etc.).
  • Security: Ensure the controller only exposes authorized data.
  • Performance: For large datasets, consider virtual scrolling or remote paging.
  • Styling: Extend or override more Syncfusion CSS classes to match corporate branding.

*Happy coding! 🚀 *