๐ GCLicenseReport.cshtml Documentation
๐ Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- Model & Data Binding
- Layout & ViewData
- ๐จ Custom CSS Styling
- ๐ UI Structure
- ๐ Syncfusion EJ2 Grid Configuration
7.1 Grid Features
7.2 Columns Definition
7.3 Toolbar & Export - ๐ ๏ธ JavaScript Logic & Event Handlers
8.1 Clear Search Button
8.2 Excel Export Handler - ๐ Usage Example
- ๐ UML Diagram
- โ 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:
LicenseReportholds fields likeState,LicenseNumber,Status, etc. - DataSource: Passed via
ViewBag.datasource(e.g., aList<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.cshtmlor 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
toolbarClickJS 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.keyto 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
- Controller Action
public IActionResult GCLicenseReport() { var licenseList = _licenseService.GetContractorLicenses(); ViewBag.datasource = licenseList; return View(); } - View Rendering
- Navigate to
/AccountingImaging/GCLicenseReport - The grid auto-populates with
licenseList.
- Navigate to
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