๐ ECLicenseReport.cshtml Documentation
Path:
IrbyImaging/Views/AccountingImaging/ECLicenseReport.cshtml
๐ Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- Data Models & View Models
- Page Layout & Styles
- Syncfusion Grid Configuration
- Toolbar & Button Actions
- Client-Side Scripting
- Key Functional Areas
- Error Handling & Return Types
- Third-Party Integrations
- Sample Code Blocks & Usage Examples
- UML Diagrams
- 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:
StateLicenseNumberLicenseClassificationsClassificationCodesIssuingPartyDateAcquiredStatusExpirationDateRenewalStatusQualifiers
ViewBag.datasource: An
IEnumerable<LicenseReport>passed from the Controller to populate the grid.
๐จ Page Layout & Styles
- Title & Metadata
@{ ViewData["Title"] = "List"; } - Bootstrap Cards & Grid
.row,.col-12,.card,.card-bodyfor responsive layout
- 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
- Initialization
- Razor sets up grid ID, data source, columns, and features.
- Data Binding
- Uses
@ViewBag.datasourceto fill rows.
- Uses
- Filtering & Searching
- Excelโstyle filter bar & global search toolbar.
- Sorting & Grouping
- Clickable headers and vertical grouping by column.
- Paging
- Builtโin page navigation controls.
- Excel Export
- Oneโclick export via
gridObj.excelExport().
- Oneโclick export via
- 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.
- No explicit error catch in this view:
- HTTP Responses
- Standard
200 OKwhen view renders successfully. 500 Internal Server Errorif model binding fails or an exception occurs server-side.
- Standard
๐ Third-Party Integrations
- Syncfusion EJ2
- Provides the
<ejs-grid>control. - Features: Filtering, Grouping, Sorting, Paging, Export.
- Provides the
- Bootstrap
- Layout classes (
row,card, etc.) assume Bootstrap CSS is loaded in the master layout.
- Layout classes (
๐ก 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! ๐