📄 Documentation: DocumentTypes.cshtml
Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- View Models & Data Models
- Key Functional Areas
4.1 ➕ Add New Document Type Button
4.2 🔎 Search Functionality
4.3 🌳 Syncfusion TreeGrid Configuration
4.4 📦 Modal for “View Indexes” - Helper Methods & Utilities
- API Endpoints Overview
- Third‑party Integrations
- Sample Code Blocks & Usage Examples
- UML Diagrams
- Conclusion
🎯 Overview & Purpose
DocumentTypes.cshtml is an ASP.NET MVC Razor view located under IrbyImaging/Views/HRImaging/. It renders a TreeGrid of document types, allowing users to:
- Add, search, edit, delete, and export document types
- Display a hierarchical view (parents → children) via Syncfusion EJ2 TreeGrid
- Load index details in a modal popup
This page is part of the HRImaging module, used to maintain a catalog of document types and their associated indexes in the Irby Imaging platform.
⚙️ Dependencies & Technologies
| Layer | Technology / Library |
|---|---|
| Server‑side | ASP.NET MVC (Razor), C# |
| UI Components | Syncfusion EJ2 TreeGrid |
| JavaScript Libs | jQuery, DataTables, jszip, pdfmake |
| CSS & Layout | Bootstrap 5, MetisMenu, SimpleBar, Node‑Waves |
| Modal & Popups | Bootstrap modal, Syncfusion DialogUtility |
👥 View Models & Data Models
DocumentTypeView (UI Model)
The @model for this view is IrbyImaging.UI.Models.DocumentTypeView.
public class DocumentTypeView {
public int Id { get; set; }
public string Type { get; set; }
public string AttributeList { get; set; }
public string Category { get; set; }
public bool IsAvailable { get; set; }
public bool IsDeleted { get; set; }
public string AddedBy { get; set; }
public DateTime AddedDate { get; set; }
public string ModifiedBy { get; set; }
public DateTime ModifiedDate { get; set; }
public List<DocumentTypeView> Children { get; set; }
}
- Children: used by TreeGrid’s
childMappingto display hierarchical data. - Other properties map 1‑1 to DB fields in the underlying DocumentType entity.
🔑 Key Functional Areas
➕ Add New Document Type Button
<a asp-action="CreateType" class="btn btn-success irby-green">
Add New Document Type
</a>
- asp‑action="CreateType": invokes the controller’s CreateType (GET) action.
- Styled as a green Bootstrap button.
🔎 Search Functionality
<input type="text" id="searchText">
<ejs-button id="Search" content="Search" cssClass="e-primary"></ejs-button>
document.getElementById('Search').addEventListener('click', function () {
var val = document.getElementById('searchText').value;
var treegrid = document.getElementById('TreeGrid').ej2_instances[0];
treegrid.search(val);
});
- Client‑side search using EJ2 TreeGrid’s
.search()API. - Text input bound to
#searchText; triggers full‑grid search.
🌳 Syncfusion TreeGrid Configuration
<ejs-treegrid id="TreeGrid"
dataSource="ViewBag.dataSource"
childMapping="Children"
treeColumnIndex="0"
allowPaging="true"
pageSettings="{ pageSize: 10 }"
allowFiltering="true"
filterSettings="{ type: 'Excel' }"
allowSorting="true"
allowReordering="true"
allowTextWrap="true"
allowExcelExport="true"
allowPdfExport="true"
toolbar="@(new List<string> { "ExcelExport", "CsvExport", "PdfExport", "Print" })"
toolbarClick="toolbarClick"
load="load"
width="auto"
height="100%"
gridLines="Both">
<e-treegrid-columns>
<!-- Field definitions -->
</e-treegrid-columns>
</ejs-treegrid>
Column Definitions
| Field | HeaderText | Template | Filtering | Sorting | Width | TextAlign |
|---|---|---|---|---|---|---|
| Type | Type | — | ✓ | ✓ | 220 | Left |
| AttributeList | Index List | #typetemplate |
✓ | ✓ | 150 | Left |
| Category | Category | — | ✓ | ✓ | 220 | Left |
| IsAvailable | Is Available | — | ✓ | ✓ | 130 | Center |
| IsDeleted | Is Deleted | — | ✓ | ✓ | 120 | Center |
| AddedBy | Added By | — | ✓ | ✓ | 150 | Left |
| AddedDate | Added Date | — | ✓ | ✓ | 140 | Center |
| ModifiedBy | Modified By | — | ✓ | ✓ | 150 | Left |
| ModifiedDate | Modified Date | — | ✓ | ✓ | 140 | Center |
| Edit | Edit | #edittemplate |
✓ | ✓ | 130 | Center |
| Delete | Delete | #deletetemplate |
✓ | ✓ | 120 | Center |
- childMapping="Children": recursively displays nested types.
- toolbarClick and load events wired to handle export & date formatting.
📦 Modal for “View Indexes”
<script id="typetemplate" type="text/x-template">
<a href="javascript:void(0);" class="anchorDetail" data-id=${Id}>View Indexes</a>
</script>
...
<div id='myModal' class='modal'>…</div>
$(function () {
$(".anchorDetail").click(function () {
var id = $(this).data('id');
$.ajax({
type: "GET",
url: '/HRImaging/myModal',
data: { id: id },
success: function (data) {
$('#myModalContent').html(data);
$('#myModal').modal('show');
},
error: function () { alert("Dynamic content load failed."); }
});
});
});
- Clicking View Indexes loads a partial view via AJAX into
#myModalContent, then displays the Bootstrap modal.
🛠 Helper Methods & Utilities
| Function | Purpose |
|---|---|
load() |
Sets date‑format for AddedDate & ModifiedDate columns |
toolbarClick() |
Handles Excel, CSV, PDF export commands with state persistence |
onChange(args) |
Toggles isCollapsedStatePersist for export |
onChange(e) |
Dynamically changes gridLines setting |
| Search event | Binds click on Search button to call .search(val) |
🔗 API Endpoints Overview
| URL | Method | Description |
|---|---|---|
/HRImaging/CreateType |
GET | Show “Add New Document Type” form |
/HRImaging/EditType/{id} |
GET | Load edit form in new window/tab |
/HRImaging/DeleteType/{id} |
GET | Trigger delete confirmation |
/HRImaging/myModal?id={id} |
GET | Return partial view of index list |
🔌 Third‑party Integrations
- Syncfusion EJ2: TreeGrid, Button, DialogUtility
- jQuery: DOM manipulation, AJAX
- DataTables & extensions: additional export utilities
- jszip & pdfmake: generation of ZIP/PDF for exports
- Bootstrap: layout, modal dialogs
- MetisMenu, SimpleBar, Node‑Waves: sidebar/menu, scrollbars, ripple effects
💻 Sample Code Blocks & Usage Examples
1. Initializing the TreeGrid in Razor
<ejs-treegrid id="TreeGrid"
dataSource="ViewBag.dataSource"
childMapping="Children"
treeColumnIndex="0"
allowPaging="true"
pageSettings="{ pageSize: 10 }"
toolbar="@(new List<string> { "ExcelExport", "CsvExport", "PdfExport", "Print" })"
toolbarClick="toolbarClick"
load="load">
<!-- columns -->
</ejs-treegrid>
2. AJAX Partial‑View Load for Modal
$.ajax({
type: "GET",
url: '/HRImaging/myModal',
data: { id: selectedId },
success: function(html) {
$('#myModalContent').html(html);
$('#myModal').modal('show');
}
});
📝 UML Diagrams
Class Diagram
classDiagram
class DocumentTypeView {
+int Id
+string Type
+string AttributeList
+string Category
+bool IsAvailable
+bool IsDeleted
+string AddedBy
+DateTime AddedDate
+string ModifiedBy
+DateTime ModifiedDate
+List~DocumentTypeView~ Children
}
Sequence Diagram: “View Indexes” Flow
sequenceDiagram
User->>Browser: Click “View Indexes”
Browser->>Server: GET /HRImaging/myModal?id=123
Server-->>Browser: Partial‑View HTML
Browser->>Browser: Insert into #myModalContent
Browser->>User: Show Bootstrap modal
🎁 Conclusion
This DocumentTypes.cshtml view provides a rich, interactive interface to manage document types within the HRImaging module. Leveraging Syncfusion EJ2 TreeGrid for hierarchical display, AJAX‑driven modals for details, and robust export capabilities (Excel, CSV, PDF), it offers end users a powerful toolset for day‑to‑day document catalog management.
Feel free to extend column templates, customize export settings, or integrate additional filters to fit your business needs. Happy coding! 🚀