đ GetDocumentCategories.cshtml Documentation
Table of Contents
- Overview & Purpose
- File Structure
- Dependencies & Technologies
- View Model & Data Model
- Key Functional Areas
5.1 Layout & Metadata
5.2 Styling & Theming
5.3 Grid Initialization & Configuration
5.4 Column Definitions
5.5 Filtering, Editing & Paging - Client-Side Scripting (Events)
- Helper Methods & Utilities
- Error Handling & Return Types
- API Endpoints Overview
- ThirdâParty Integrations
- UML Diagram
- Sample Code Snippets
- Usage Example
- Conclusion
1. Overview & Purpose
đ GetDocumentCategories.cshtml is a Razor View in the IrbyImaging application (under LegalImaging). It renders an interactive Syncfusion EJ2 Grid to display and manage legal document categories and their indexing metadata.
Key user capabilities:
- đ Search, đą Sort, đ Group, đ Filter
- đ Add/Edit/Delete rows inline
- đŠ Export to Excel
- đ DragâandâDrop rows and Paging for large datasets
2. File Structure
IrbyImaging/
âââ Views/
âââ LegalImaging/
âââ GetDocumentCategories.cshtml
- Model:
IrbyImaging.UI.Models.LegalDocumentCategories - Layout:
~/Views/Shared/_LegalLayout.cshtml
3. Dependencies & Technologies
| Technology | Purpose |
|---|---|
| ASP.NET Core MVC (Razor) | Serverâside view rendering and model binding |
| Syncfusion EJ2 Grid | Rich, interactive grid with sorting/filter/grouping/CRUD |
| Bootstrap | Responsive layout (card, row, colâ*) |
| JavaScript (ES6) | Clientâside event handling |
| CSS | Custom theming of Syncfusion grid elements |
4. View Model & Data Model
namespace IrbyImaging.UI.Models
{
public class LegalDocumentCategories
{
public string DocumentCategory { get; set; } // e.g. "Contracts"
public string DocumentType { get; set; } // e.g. "NDA"
public string IndexName { get; set; } // e.g. "ClientName"
public bool MultiValueIndex { get; set; } // e.g. true/false
public string IndexValue { get; set; } // e.g. "ABC Corp"
public string IndexType { get; set; } // e.g. "String"
}
}
- Data is supplied to the grid via
ViewBag.datasourceâaList<LegalDocumentCategories>.
5. Key Functional Areas
5.1 Layout & Metadata
@model IrbyImaging.UI.Models.LegalDocumentCategories
@using Syncfusion.JavaScript
@using Syncfusion.JavaScript.Models
@{
ViewData["Title"] = "List";
Layout = "~/Views/Shared/_LegalLayout.cshtml";
}
- @model: stronglyâtypes the view
- ViewData["Title"]: sets the browser page title
- Layout: inherits from a shared legalâsection layout
5.2 Styling & Theming
<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; }
/* âŠmore custom rules targeting .e-grid⊠*/
</style>
- Custom CSS overrides Syncfusion defaults for borders, colors, icons, group captions, etc.
5.3 Grid Initialization & 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">
- Features Enabled:
- Sorting, Grouping, Filtering (Excel style)
- Drag & Drop, Paging, Text Wrap
- Search and ExcelExport on the toolbar
5.4 Column Definitions
| Field | Header Text | Alignment | Primary Key | Width |
|---|---|---|---|---|
| DocumentCategory | Document Category | Left | â | auto |
| DocumentType | Document Type | Left | â | auto |
| IndexName | Index Name | Left | â | auto |
| MultiValueIndex | Multi Value Index | Center | â | auto |
| IndexValue | Index Value | Left | â | auto |
| IndexType | Index Type | Left | â | 110px |
5.5 Filtering, Editing & Paging
<e-grid-filterSettings type="Excel"></e-grid-filterSettings>
<e-grid-editSettings allowAdding="true"
allowEditing="true"
allowDeleting="true"
edit-mode="Normal"></e-grid-editSettings>
- Excelâstyle filters on columns
- Inline Add/Edit/Delete operations
- Normal edit mode
6. Client-Side Scripting (Events)
// Clear search box
document.getElementById('clear').addEventListener('click', () => {
const gridObj = document.getElementById("Grid").ej2_instances[0];
gridObj.searchSettings.key = '';
});
// Toolbar button handler
function toolbarClick(args) {
const gridObj = document.getElementById("Grid").ej2_instances[0];
if (args.item.id === 'Grid_excelexport') {
gridObj.excelExport();
}
}
- Clear button resets the gridâs search key
- toolbarClick intercepts the Excel Export button
7. Helper Methods & Utilities
| Utility | Description |
|---|---|
| Clear Search | Clears the current search filter |
| toolbarClick() | Delegates toolbar actions (Excel) |
8. Error Handling & Return Types
- Razor views donât explicitly return values.
- Clientâside events can be extended with
errorcallbacks if needed.
9. API Endpoints Overview
This view has no direct AJAX calls.
Data is provided by the controller action, for example:
public IActionResult GetDocumentCategories()
{
ViewBag.datasource = _documentService.GetAllCategories();
return View(new LegalDocumentCategories());
}
10. ThirdâParty Integrations
- Syncfusion EJ2:
<ejs-grid>, filtering, sorting, grouping, export - Bootstrap: responsive card layout
11. UML Diagram
@startuml
actor User
participant Browser
participant View as "GetDocumentCategories.cshtml"
participant SyncfusionGrid
User -> Browser: HTTP GET /LegalImaging/GetDocumentCategories
Browser -> View: Render HTML + Scripts
View -> SyncfusionGrid: Initialize(dataSource)
User -> SyncfusionGrid: Search / Sort / Export
SyncfusionGrid -> Browser: Client-side rendering
@enduml
12. Sample Code Snippets
Grid Columns
<ejs-grid-columns>
<e-grid-column field="DocumentCategory"
headerText="Document Category"
isPrimaryKey="true"
textAlign="Left">
</e-grid-column>
<!-- âŠother columns⊠-->
</ejs-grid-columns>
Filter Settings
<e-grid-filterSettings type="Excel"></e-grid-filterSettings>
13. Usage Example
- Controller
[HttpGet] public IActionResult GetDocumentCategories() { ViewBag.datasource = _repo.GetCategories(); return View(new LegalDocumentCategories()); } - Link in Navbar
<a asp-area="LegalImaging" asp-controller="LegalImaging" asp-action="GetDocumentCategories"> Document Categories </a> - Run & Interact
- Navigate to
/LegalImaging/GetDocumentCategories - Use search, sorting, grouping, export, CRUD
- Navigate to
14. Conclusion
đ The GetDocumentCategories.cshtml view offers a fullâfeatured, endâtoâend solution for managing legal document categories within IrbyImaging, combining ASP.NET Core MVCâs razor engine with Syncfusion EJ2 Gridâs rich UI capabilities. Its modular layout, comprehensive configuration, and clear JavaScript events make it both powerful and extensible for future enhancements.
Happy coding! đ