📄 GetDocumentCategories.cshtml Documentation

Table of Contents

  1. Overview & Purpose
  2. File Structure
  3. Dependencies & Technologies
  4. View Model & Data Model
  5. 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
  6. Client-Side Scripting (Events)
  7. Helper Methods & Utilities
  8. Error Handling & Return Types
  9. API Endpoints Overview
  10. Third‑Party Integrations
  11. UML Diagram
  12. Sample Code Snippets
  13. Usage Example
  14. 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—a List<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 error callbacks 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

  1. Controller
    [HttpGet]
    public IActionResult GetDocumentCategories()
    {
        ViewBag.datasource = _repo.GetCategories();
        return View(new LegalDocumentCategories());
    }
    
  2. Link in Navbar
    <a asp-area="LegalImaging"
       asp-controller="LegalImaging"
       asp-action="GetDocumentCategories">
       Document Categories
    </a>
    
  3. Run & Interact
    • Navigate to /LegalImaging/GetDocumentCategories
    • Use search, sorting, grouping, export, CRUD

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! 🚀