๐Ÿ“„ ECLicenseReport.cshtml Documentation

Path: IrbyImaging/Views/AccountingImaging/ECLicenseReport.cshtml


๐Ÿ“‘ Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. Data Models & View Models
  4. Page Layout & Styles
  5. Syncfusion Grid Configuration
  6. Toolbar & Button Actions
  7. Client-Side Scripting
  8. Key Functional Areas
  9. Error Handling & Return Types
  10. Third-Party Integrations
  11. Sample Code Blocks & Usage Examples
  12. UML Diagrams
  13. Conclusion

๐Ÿ” Overview & Purpose

ECLicenseReport.cshtml is an ASP.NET Core Razor View designed to display an Electrical Contractor License Report in an interactive, filterable, sortable, and exportable grid. This view leverages Syncfusion EJ2 components to provide rich UI features:

  • Searching, Filtering, Sorting, Grouping, Paging
  • Excel Export & Real-time Search Clearing
  • Custom CSS Styling for headers, grouping, and row expand/collapse

Objectives

  • Present license data in a clean, tabular format
  • Allow endโ€‘users to interactively manipulate the data
  • Support export of data to Excel with builtโ€‘in Syncfusion functionality

โš™๏ธ Dependencies & Technologies

Category Technology / Library
Server-Side ASP.NET Core MVC / Razor Views
Client-Side UI Controls Syncfusion EJ2 JavaScript Grid (ejs-grid)
Script Interop Syncfusion.JavaScript, Syncfusion.EJ2 Models
Styling Custom CSS, Bootstrap (via card, row, etc.)
@using Syncfusion.JavaScript
@using Syncfusion.JavaScript.Models
@using Syncfusion.EJ2

๐Ÿ“ฆ Data Models & View Models

This view is strongly typed to:

@model IrbyImaging.DomainClasses.LicenseReport
  • LicenseReport (Domain Model) โ€“ Contains properties for:
    • State
    • LicenseNumber
    • LicenseClassifications
    • ClassificationCodes
    • IssuingParty
    • DateAcquired
    • Status
    • ExpirationDate
    • RenewalStatus
    • Qualifiers

ViewBag.datasource: An IEnumerable<LicenseReport> passed from the Controller to populate the grid.


๐ŸŽจ Page Layout & Styles

  1. Title & Metadata
    @{ ViewData["Title"] = "List"; }
    
  2. Bootstrap Cards & Grid
    • .row, .col-12, .card, .card-body for responsive layout
  3. Custom CSS
    <style>
      .e-grid .e-gridheader { border: 2px solid black; }
      .e-grid .e-headercell { color: darkblue; }
      /* ... many other classes for sort icons, grouping, indent cells ... */
    </style>
    

๐Ÿ—‚ Syncfusion Grid Configuration

<ejs-grid
  id="Grid"
  gridLines="Both"
  allowSorting="true"
  allowGrouping="true"
  allowFiltering="true"
  allowRowDragAndDrop="true"
  allowPaging="true"
  allowTextWrap="true"
  dataSource="@ViewBag.datasource"
  allowExcelExport="true"
  toolbar="@( new List<string>{"ExcelExport","Search"} )"
  toolbarClick="toolbarClick">
  
  <!-- Filter Settings -->
  <e-grid-filterSettings type="Excel"></e-grid-filterSettings>
  
  <!-- Edit Settings -->
  <e-grid-editSettings
    allowAdding="true"
    allowEditing="true"
    allowDeleting="true"
    edit-mode="@(EditMode.Normal)">
  </e-grid-editSettings>
  
  <!-- Columns Definition -->
  <e-grid-columns>
    <e-grid-column field="State"              headerText="STATE"                    isPrimaryKey="true"></e-grid-column>
    <e-grid-column field="LicenseNumber"      headerText="LICENSE NUMBER"           isPrimaryKey="true"></e-grid-column>
    <e-grid-column field="LicenseClassifications"
                   headerText="LICENSE CLASSIFICATION(S)"
                   textAlign="Left"
                   isPrimaryKey="true"></e-grid-column>
    <e-grid-column field="ClassificationCodes"
                   headerText="CLASSIFICATION CODE(S)"
                   textAlign="Center"></e-grid-column>
    <e-grid-column field="IssuingParty"     headerText="ISSUED BY"></e-grid-column>
    <e-grid-column field="DateAcquired"     headerText="ACQUIRED ON"></e-grid-column>
    <e-grid-column field="Status"           headerText="STATUS"></e-grid-column>
    <e-grid-column field="ExpirationDate"   headerText="EXPIRES ON"></e-grid-column>
    <e-grid-column field="RenewalStatus"    headerText="RENEWAL STATUS"></e-grid-column>
    <e-grid-column field="Qualifiers"       headerText="QUALIFIER(S)"></e-grid-column>
  </e-grid-columns>
</ejs-grid>

Column Breakdown

FieldName HeaderText Alignment Notes
State STATE Left Primary Key
LicenseNumber LICENSE NUMBER Left Primary Key
LicenseClassifications LICENSE CLASSIFICATION(S) Left Primary Key
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 โ€”

๐Ÿ›  Toolbar & Button Actions

  • Clear Search Button

    <ejs-button id="clear" content="Clear Search"></ejs-button>
    
  • Builtโ€‘in Toolbar Options

    • ExcelExport
    • Search

๐Ÿ’ป Client-Side Scripting

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

  // Handle toolbar clicks (ExcelExport)
  function toolbarClick(args) {
    var gridObj = document.getElementById("Grid").ej2_instances[0];
    if (args.item.id === 'Grid_excelexport') {
      gridObj.excelExport();
    }
  }
</script>

๐ŸŒŸ Key Functional Areas

  1. Initialization
    • Razor sets up grid ID, data source, columns, and features.
  2. Data Binding
    • Uses @ViewBag.datasource to fill rows.
  3. Filtering & Searching
    • Excelโ€‘style filter bar & global search toolbar.
  4. Sorting & Grouping
    • Clickable headers and vertical grouping by column.
  5. Paging
    • Builtโ€‘in page navigation controls.
  6. Excel Export
    • Oneโ€‘click export via gridObj.excelExport().
  7. Custom Styling
    • CSS classes for visual cues (blue headers, italic group captions).

๐Ÿ›ก Error Handling & Return Types

  • View Returns
    • This Razor view returns HTML and JavaScript to the browser.
  • Error Handling
    • No explicit error catch in this view:
      • Data errors should be handled in Controller/Service layer.
      • Syncfusion grid will log JavaScript errors in browser console.
  • HTTP Responses
    • Standard 200 OK when view renders successfully.
    • 500 Internal Server Error if model binding fails or an exception occurs server-side.

๐Ÿ”— Third-Party Integrations

  • Syncfusion EJ2
    • Provides the <ejs-grid> control.
    • Features: Filtering, Grouping, Sorting, Paging, Export.
  • Bootstrap
    • Layout classes (row, card, etc.) assume Bootstrap CSS is loaded in the master layout.

๐Ÿ’ก Sample Code Blocks & Usage Examples

1. Controller Action Example

public IActionResult ECLicenseReport()
{
    // 1. Fetch data from database or service
    List<LicenseReport> licenses = _licenseService.GetAllLicenses();

    // 2. Pass the list both as Model & ViewBag.datasource
    ViewBag.datasource = licenses;
    return View("ECLicenseReport", licenses);
}

2. Adding the View to a Menu

<li class="nav-item">
  <a class="nav-link" asp-controller="AccountingImaging" asp-action="ECLicenseReport">
    Electrical Contractor Licenses ๐Ÿ“‹
  </a>
</li>

3. Exporting to Excel

  • User Action: Click on the Excel icon in the toolbar.
  • Under the Hood:
    gridObj.excelExport();
    

๐Ÿงฉ UML Diagrams

Sequence Diagram

sequenceDiagram
  participant C as Controller
  participant V as ECLicenseReport View
  participant G as SyncfusionGrid
  participant U as User

  C->>V: Pass Model + ViewBag.datasource
  V->>G: Initialize Grid with Data
  U->>G: Click Sort / Filter / Search
  G-->>U: Render Filtered/Sorted Rows
  U->>#clear: Click "Clear Search"
  #clear->>G: gridObj.searchSettings.key=''
  U->>G: Click "ExcelExport"
  G->>G: execute excelExport()
  G-->>U: Download Excel file

Class Diagram

classDiagram
  class LicenseReport {
    +string State
    +string LicenseNumber
    +string LicenseClassifications
    +string ClassificationCodes
    +string IssuingParty
    +DateTime DateAcquired
    +string Status
    +DateTime ExpirationDate
    +string RenewalStatus
    +string Qualifiers
  }
  class ECLicenseReportView {
    +@model LicenseReport
    +ViewBag.datasource : IEnumerable<LicenseReport>
    +Render()
  }
  LicenseReport <|-- ECLicenseReportView : Binds

๐Ÿ Conclusion

The ECLicenseReport.cshtml view delivers a robust, interactive interface for managing electrical contractor licenses. By combining Syncfusion EJ2 grids with ASP.NET Core Razor and custom styling, it empowers end-users to:

  • Quickly locate, sort, group, and filter license records
  • Export data seamlessly to Excel
  • Maintain a clear, userโ€‘friendly layout

Next Steps:

  • Integrate server-side validation on license data.
  • Enhance accessibility (ARIA labels).
  • Add unit/integration tests for the Controller and Model.
  • Consider caching large datasets for performance.

Developers can now leverage this documentation to understand, maintain, and extend the ECLicenseReport functionality with confidence! ๐Ÿš€