๐Ÿ“„ GCLicenseReport.cshtml Documentation


๐Ÿ“‘ Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. Model & Data Binding
  4. Layout & ViewData
  5. ๐ŸŽจ Custom CSS Styling
  6. ๐Ÿ“ UI Structure
  7. ๐Ÿ“Š Syncfusion EJ2 Grid Configuration
    7.1 Grid Features
    7.2 Columns Definition
    7.3 Toolbar & Export
  8. ๐Ÿ› ๏ธ JavaScript Logic & Event Handlers
    8.1 Clear Search Button
    8.2 Excel Export Handler
  9. ๐Ÿš€ Usage Example
  10. ๐Ÿ“Š UML Diagram
  11. โœ… Conclusion

1. Overview & Purpose

This Razor View (GCLicenseReport.cshtml) renders a General Contractor License Report grid for Accounting Imaging. It displays licensing data (state, number, classifications, dates, etc.) in an interactive, filterable, groupable table powered by Syncfusion EJ2 Grid.

  • Intended Use:
    • Enable Accounting/Legal teams to search, filter, group, and export contractor license data.
    • Provide quick Excel export for offline analysis.

2. Dependencies & Technologies

Dependency Purpose
Syncfusion.EJ2 Core EJ2 JavaScript UI components
Syncfusion.EJ2.Grids EJ2 Grid control
.NET Core Razor (CSHTML) Serverโ€‘side view rendering
IrbyImaging.DomainClasses.LicenseReport Stronglyโ€‘typed ViewModel

๐ŸŽฏ Key Concepts:

  • ViewModel Binding using @model
  • ViewBag for dynamic data injection
  • Syncfusion EJ2 for rich grid features

3. Model & Data Binding

@model IrbyImaging.DomainClasses.LicenseReport
@{
    ViewData["Title"] = "List";
    // Layout can be customized:
    // Layout = "~/Views/Shared/_LegalLayout.cshtml";
}
  • Model: LicenseReport holds fields like State, LicenseNumber, Status, etc.
  • DataSource: Passed via ViewBag.datasource (e.g., a List<LicenseReport> from the Controller).

4. Layout & ViewData

  • Title is set to "List".
  • Optionally you can specify a custom Layout (commented out).
  • All Syncfusion scripts/styles must be referenced in _Layout.cshtml or bundler.

5. ๐ŸŽจ Custom CSS Styling

The view includes inline CSS to style the EJ2 Grid:

.e-grid .e-gridheader { border: 2px solid black; }
.e-grid .e-headercell { color: darkblue; }
.e-grid .e-sortnumber { background-color: #deecf9; font-family: cursive; }
/* Custom icons mapping */
.e-grid .e-icon-ascending::before { content: '\e306'; }
/* ... additional styles for grouping, expand/collapse ... */
Class Effect
.e-gridheader Black border on header
.e-headercell Dark blue header text
.e-sortnumber Light-blue background for sort index
.e-recordplusexpand / .e-recordpluscollapse Custom background for expand/collapse buttons

6. ๐Ÿ“ UI Structure

<h2>General Contractor Licenses</h2>
<div class="row">
  <div class="col-12">
    <div class="card">
      <div class="card-body">
        <div id="ControlRegion">
          <h4 class="card-title mb-4">License Report:</h4>
          <ejs-button id="clear" content="Clear Search"></ejs-button>
          <ejs-grid id="Grid" ...>
            <!-- Columns & Settings here -->
          </ejs-grid>
        </div>
      </div>
    </div>
  </div>
</div>
  • Bootstrap layout classes (row, col-12, card, etc.)
  • ControlRegion wrapper for toolbar + grid

7. ๐Ÿ“Š Syncfusion EJ2 Grid Configuration

7.1 Grid Features

<ejs-grid
    id="Grid"
    gridLines="Both"
    allowSorting="true"
    allowFiltering="true"
    allowPaging="true"
    allowGrouping="true"
    allowRowDragAndDrop="true"
    allowTextWrap="true"
    allowExcelExport="true"
    toolbar="@(new List<string>{"ExcelExport","Search"})"
    dataSource="@ViewBag.datasource"
    toolbarClick="toolbarClick">
  ...
</ejs-grid>
Option Description
allowSorting Click header to sort
allowFiltering Excelโ€‘style filter UI
allowGrouping Drag columns to group
allowPaging Paged data
allowTextWrap Wordโ€‘wrap in cells
toolbar Buttons: ExcelExport, Search
allowExcelExport Enable gridObj.excelExport()

7.2 Columns Definition

Field Header Text Key? Alignment
State STATE Yes Left
LicenseNumber LICENSE NUMBER Yes Left
LicenseClassifications LICENSE CLASSIFICATION(S) Yes 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

Example snippet:

<e-grid-columns>
  <e-grid-column field="State" headerText="STATE" isPrimaryKey="true"></e-grid-column>
  <!-- other columns -->
</e-grid-columns>

7.3 Toolbar & Export

  • ExcelExport button on toolbar triggers toolbarClick JS handler.
  • Search box allows quick text search across all columns.

8. ๐Ÿ› ๏ธ JavaScript Logic & Event Handlers

// Clear Search Button
document.getElementById('clear').addEventListener('click', () => {
  const grid = document.getElementById("Grid").ej2_instances[0];
  grid.searchSettings.key = '';
});

// Toolbar Click for Excel Export
function toolbarClick(args) {
  const grid = document.getElementById("Grid").ej2_instances[0];
  if (args.item.id === 'Grid_excelexport') {
    grid.excelExport();
  }
}

8.1 Clear Search Button

  • ID: clear
  • Action: Resets grid.searchSettings.key to an empty string, clearing search filter.

8.2 Excel Export Handler

  • Event: toolbarClick
  • Check: args.item.id === 'Grid_excelexport'
  • Action: Calls grid.excelExport() to download the current view as an Excel file.

9. ๐Ÿš€ Usage Example

  1. Controller Action
    public IActionResult GCLicenseReport()
    {
        var licenseList = _licenseService.GetContractorLicenses();
        ViewBag.datasource = licenseList;
        return View();
    }
    
  2. View Rendering
    • Navigate to /AccountingImaging/GCLicenseReport
    • The grid auto-populates with licenseList.

10. ๐Ÿ“Š UML Diagram

+-------------------------+
|  LicenseReport (Model)  |
+-------------------------+
| - State                 |
| - LicenseNumber         |
| - LicenseClassifications|
| - ClassificationCodes   |
| - IssuingParty          |
| - DateAcquired          |
| - Status                |
| - ExpirationDate        |
| - RenewalStatus         |
| - Qualifiers            |
+-------------------------+

        โ–ฒ Razor View
        |
+-------------------------------+
|  GCLicenseReport.cshtml      |
+-------------------------------+
| - Renders Syncfusion EJ2 Grid|
| - Binds List<LicenseReport>  |
| - Custom CSS/JS handlers     |
+-------------------------------+
  • MVC Flow: Controller โ†’ ViewBag โ†’ Razor View โ†’ Browser with Syncfusion EJ2 Grid UI

11. โœ… Conclusion

This GCLicenseReport.cshtml view elegantly presents a General Contractor License dataset with powerful grid featuresโ€”sorting, filtering, grouping, and Excel exportโ€”by leveraging Syncfusion EJ2 and Razor.

  • Extend by adding custom commands, row templates, or additional toolbar buttons.
  • Internationalize headers via resource files.
  • Secure by enforcing role-based access in the Controller.

Enjoy your interactive license report! ๐Ÿš€๐ŸŽ‰


End of Documentation