đ GetDocumentCategories.cshtml Documentation
Table of Contents
- Overview & Purpose
- Key Functional Areas
- Dependencies & Technologies
- View Models & Data Models
- Layout & Styling
- Grid Component Configuration
- ClientâSide Scripting
- Helper Methods & Utilities
- Error Handling & Return Types
- API Endpoints Overview
- ThirdâParty Integrations
- UML Diagram
- Sample Usage & Code Snippets
- Conclusion
1. Overview & Purpose
GetDocumentCategories.cshtml is an ASP.NET Razor View under the IrbyImaging/Views/AccountingImaging folder. It renders a Syncfusion EJ2 Grid to display and manage Legal Document Categories and their associated Document Types and Indices.
- đ Scenario: Accounting or Legal department users need to view, add, edit, delete, filter, sort, group, search, and export document category records.
- đ Functionality:
- CRUD operations on categories/types
- Excel export & search toolbar
- Paging, grouping, filtering, sorting
- Row dragâandâdrop
- Custom styling
2. Key Functional Areas
| Area | Description |
|---|---|
| Display & Layout | Uses Bootstrap cards and rows/columns to structure the UI. |
| Data Grid | Implements ejs-grid from Syncfusion for rich data manipulation. |
| CRUD Operations | Inline add, edit, and delete via the gridâs editSettings. |
| Filtering & Sorting | Excelâstyle filtering, multiâcolumn sorting, grouping, and global search. |
| Export | Toolbar button for Excel export (ExcelExport). |
| Custom Styling | CSS overrides for headers, icons, grouping, and row expand/collapse visuals. |
| ClientâSide Scripting | Vanilla JS for âClear Searchâ and toolbar click handling. |
3. Dependencies & Technologies
| Dependency | Version / Tech | Purpose |
|---|---|---|
| ASP.NET Core MVC Razor | ASP.NET Core 3.x / 5.x (typical) | MVC View Engine |
| Syncfusion.EJ2 | v17+ | Data Grid & UI controls |
| Syncfusion.JavaScript.Models | â | Stronglyâtyped grid configuration in Razor |
| Bootstrap 4/5 | â | Layout & responsive grid |
NuGet & Script References (assumed in _Layout.cshtml):
<link href="https://cdn.syncfusion.com/ej2/material.css" rel="stylesheet" />
<script src="https://cdn.syncfusion.com/ej2/dist/ej2.min.js"></script>
4. View Models & Data Models
4.1. View Model: LegalDocumentCategories
namespace IrbyImaging.UI.Models
{
public class LegalDocumentCategory
{
public string DocumentCategory { get; set; }
public string DocumentType { get; set; }
public string IndexName { get; set; }
public bool MultiValueIndex { get; set; }
public string IndexValue { get; set; }
public string IndexType { get; set; }
}
public class LegalDocumentCategories
{
public List<LegalDocumentCategory> Categories { get; set; }
}
}
4.2. Data Source
ViewBag.datasourceis expected to be anIEnumerable<LegalDocumentCategory>or similar.- Populated in the AccountingImagingController action:
public IActionResult GetDocumentCategories()
{
var model = new LegalDocumentCategories {
Categories = _docService.FetchCategories()
};
ViewBag.datasource = model.Categories;
return View(model);
}
5. Layout & Styling
5.1. Razor & HTML Structure
@model IrbyImaging.UI.Models.LegalDocumentCategories
@using Syncfusion.JavaScript
@using Syncfusion.JavaScript.Models
@{
ViewData["Title"] = "List";
// Layout = "~/Views/Shared/_LegalLayout.cshtml";
}
<h2>Legal Document Categories/Types View</h2>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div id="ControlRegion">
<h4 class="card-title mb-4">Document Categories:</h4>
<ejs-button id="clear" content="Clear Search"></ejs-button>
<!-- Syncfusion Grid goes here -->
</div>
</div>
</div>
</div>
</div>
5.2. Custom CSS
.e-grid .e-gridheader { border:2px solid black; }
.e-grid .e-headercell { color: darkblue; }
.e-grid .e-sortnumber { background-color: #deecf9; font-family: cursive; }
.e-grid .e-groupcaption { background-color: #add8e6; font-style: italic; }
/* ...more custom overrides for icons & grouping... */
6. Grid Component Configuration
6.1. Core Grid Tag
<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"} )"
allowExcelExport="true"
toolbarClick="toolbarClick">
<!-- Filter & Edit Settings -->
<e-grid-filterSettings type="Excel"></e-grid-filterSettings>
<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="DocumentCategory" headerText="Document Category" textAlign="Left" isPrimaryKey="true"></e-grid-column>
<e-grid-column field="DocumentType" headerText="Document Type" isPrimaryKey="true"></e-grid-column>
<e-grid-column field="IndexName" headerText="Index Name" textAlign="Left" isPrimaryKey="true"></e-grid-column>
<e-grid-column field="MultiValueIndex" headerText="Multi Value Index" textAlign="Center"></e-grid-column>
<e-grid-column field="IndexValue" headerText="Index Value" textAlign="Left"></e-grid-column>
<e-grid-column field="IndexType" headerText="Index Type" textAlign="Left" width="110"></e-grid-column>
</e-grid-columns>
</ejs-grid>
6.2. Column Overview
| Field Name | Header Text | Type | Notes |
|---|---|---|---|
| DocumentCategory | Document Category | string | Primary Key |
| DocumentType | Document Type | string | Primary Key |
| IndexName | Index Name | string | Primary Key |
| MultiValueIndex | Multi Value Index | bool | Renders as checkbox or text |
| IndexValue | Index Value | string | â |
| IndexType | Index Type | string | Width = 110px |
7. ClientâSide Scripting
<script>
// Clear global search filter
document.getElementById('clear').addEventListener('click', () => {
var gridObj = document.getElementById("Grid").ej2_instances[0];
gridObj.searchSettings.key = '';
gridObj.clearSearch(); // optional: explicit clear
});
// Toolbar Excel Export handler
function toolbarClick(args) {
var gridObj = document.getElementById("Grid").ej2_instances[0];
if (args.item.id === 'Grid_excelexport') {
gridObj.excelExport();
}
}
</script>
- Clear Search: Resets
searchSettings.key. - Excel Export: Triggers
excelExport()on toolbar button click.
8. Helper Methods & Utilities
- toolbarClick(args)
Handles Syncfusion toolbar events; specifically checks for the Excel Export item. - You may extend with further helpers:
gridObj.groupColumn('DocumentCategory')gridObj.hideColumns(['IndexValue'])
9. Error Handling & Return Types
- ClientâSide: Syncfusion grid surfaces validation messages for required primary keys out-of-the-box.
- ServerâSide:
- Controller should validate incoming model during POST operations.
- Return standard
JsonResultwith status codes on AJAX requests.
- Example:
[HttpPost]
public IActionResult SaveCategory(LegalDocumentCategory item){
if(!ModelState.IsValid)
return BadRequest(ModelState);
_docService.Save(item);
return Ok(new { success = true, data = item });
}
10. API Endpoints Overview
Note: This view relies on standard CRUD endpoints in the corresponding controller. The grid performs AJAX calls implicitly if configured for remote data.
| HTTP Verb | Route | Purpose |
|---|---|---|
| GET | /AccountingImaging/GetDocumentCategories | Render the view & initial data. |
| POST | /AccountingImaging/SaveCategory | Create or Update a record. |
| DELETE | /AccountingImaging/DeleteCategory | Delete a record by key. |
11. ThirdâParty Integrations
- Syncfusion EJ2
- Grid Component
- Buttons
- Excel Export & Filter
- Bootstrap for layout
- (Optional) Font Awesome or custom icon fonts for advanced styling
12. UML Diagram
classDiagram
class LegalDocumentCategory {
+string DocumentCategory
+string DocumentType
+string IndexName
+bool MultiValueIndex
+string IndexValue
+string IndexType
}
class AccountingImagingController {
+IActionResult GetDocumentCategories()
+JsonResult SaveCategory(LegalDocumentCategory)
+JsonResult DeleteCategory(string key)
}
AccountingImagingController --> LegalDocumentCategory : uses
13. Sample Usage & Code Snippets
13.1. Controller Action
public class AccountingImagingController : Controller
{
public IActionResult GetDocumentCategories()
{
var categories = _docService.FetchCategories();
ViewBag.datasource = categories;
return View(categories);
}
[HttpPost]
public JsonResult SaveCategory([FromBody] LegalDocumentCategory model)
{
if (!ModelState.IsValid) return Json(new { success = false, errors = ModelState });
_docService.SaveOrUpdate(model);
return Json(new { success = true, data = model });
}
[HttpPost]
public JsonResult DeleteCategory([FromBody] string categoryKey)
{
_docService.Delete(categoryKey);
return Json(new { success = true });
}
}
13.2. Invoking Clear Search
<ejs-button id="clear" content="Clear Search"></ejs-button>
<script>
document.getElementById('clear').addEventListener('click', () => {
var grid = document.getElementById("Grid").ej2_instances[0];
grid.clearSearch();
});
</script>
14. Conclusion
This GetDocumentCategories.cshtml view offers a rich, interactive interface for managing legal document categories and types within the Accounting/Imaging domain. Leveraging Syncfusion EJ2, the grid supports comprehensive data operations, from inline CRUD to advanced filtering, grouping, and Excel export. By combining strong server-side models, clean Razor syntax, and targeted client-side helpers, this view delivers an efficient, user-friendly experience for power users in finance or legal departments. đ
Happy Coding! âš