📄 DocumentTypes.cshtml Documentation
Path:
IrbyImaging/Views/LegalImaging/DocumentTypes.cshtml
📑 Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- View Model
- Layout & Page Titles
- UI Components
- Template Scripts
- 6.1 Edit Template
- 6.2 Delete Template
- 6.3 Type Template
- Client-Side Scripts & Event Handlers
- Styles
- Usage Examples
- UML Diagram
- Conclusion
1. Overview & Purpose
This Razor view renders the "Document Types" management interface in the Legal Imaging area of the IrbyImaging application. Users can:
- 📋 List existing document types in a hierarchical tree grid.
- ➕ Add a new document type.
- ✏️ Edit or 🗑️ Delete individual types.
- 🔍 Search and filter types.
- 📤 Export the list (Excel, CSV, PDF, Print).
- 📑 View detailed indices via a modal popup.
Intended Audience: Legal department users and administrators who manage imaging document metadata.
2. Dependencies & Technologies
| Category | Libraries / Frameworks |
|---|---|
| Server-side | ASP.NET Core MVC / Razor |
| Client-side UI | Syncfusion EJ2 TreeGrid (Syncfusion.EJ2, Syncfusion.JavaScript) |
| JavaScript Helpers | jQuery 3.5.1, DataTables, jsZip, PDFMake, DataTables Buttons |
| CSS Framework | Bootstrap 4 |
| Modal & Menus | Bootstrap Modal, MetisMenu, SimpleBar, Waves |
3. View Model
@model IrbyImaging.UI.Models.DocumentTypeView
Key properties exposed by DocumentTypeView:
| Property | Type | Description |
|---|---|---|
Id |
int |
Unique identifier |
DocList |
IEnumerable<DocType> |
Hierarchical list of document types |
ImagingType |
string |
Category context (e.g., Legal, Safety, IT) |
IsLegal |
bool |
Flag for Legal category |
IsSafety |
bool |
Flag for Safety category |
IsIT |
bool |
Flag for IT category |
4. Layout & Page Titles
@{
ViewBag.Title = "Document Types";
ViewBag.pTitle = "Document Types";
ViewBag.pageTitle = "Document Types";
Layout = "~/Views/Shared/_LegalLayout.cshtml";
}
<h2>Document Types</h2>
- Layout:
_LegalLayout.cshtml– provides common header, sidebar, footer. - ViewBag Titles: used in page header and breadcrumbs.
5. UI Components
5.1 Add New Document Type Form
<div class="col-lg-2">
<form asp-action="CreateType">
@Html.HiddenFor(m => m.ImagingType)
@Html.HiddenFor(m => m.IsLegal)
@Html.HiddenFor(m => m.IsSafety)
@Html.HiddenFor(m => m.IsIT)
<input type="submit" value="Add New Document Type" class="btn btn-success irby-green" />
</form>
</div>
- Hidden fields propagate context flags.
- Submit navigates to the
CreateTypeaction in theLegalImagingcontroller.
5.2 Syncfusion TreeGrid
<ejs-treegrid id="TreeGrid"
dataSource="Model.DocList"
childMapping="Children"
treeColumnIndex="0"
allowFiltering="true"
allowSorting="true"
allowPaging="true"
allowExcelExport="true"
allowPdfExport="true"
toolbar="@(new List<string>{ "ExcelExport","CsvExport","PdfExport","Print" })">
<e-treegrid-pagesettings pageSize="10"></e-treegrid-pagesettings>
<e-treegrid-filtersettings type="Excel"></e-treegrid-filtersettings>
<e-treegrid-columns>
<e-treegrid-column field="Type" headerText="Type" width="220"></e-treegrid-column>
<e-treegrid-column field="AttributeList" headerText="Index List" template="#typetemplate" width="150"></e-treegrid-column>
<e-treegrid-column field="Category" headerText="Category" width="220"></e-treegrid-column>
<e-treegrid-column field="IsAvailable" headerText="Is Available" textAlign="Center" width="130"></e-treegrid-column>
<e-treegrid-column field="IsDeleted" headerText="Is Deleted" textAlign="Center" width="120"></e-treegrid-column>
<e-treegrid-column field="AddedBy" headerText="Added By" width="150"></e-treegrid-column>
<e-treegrid-column field="AddedDate" headerText="Added Date" textAlign="Center" width="140"></e-treegrid-column>
<e-treegrid-column field="ModifiedBy" headerText="Modified By" width="150"></e-treegrid-column>
<e-treegrid-column field="ModifiedDate" headerText="Modified Date" textAlign="Center" width="140"></e-treegrid-column>
<e-treegrid-column field="Edit" headerText="Edit" template="#edittemplate" width="130"></e-treegrid-column>
<e-treegrid-column field="Delete" headerText="Delete" template="#deletetemplate" width="120"></e-treegrid-column>
</e-treegrid-columns>
</ejs-treegrid>
- Hierarchical data:
childMapping="Children". - Features: Sorting, filtering, paging, export.
- Custom templates for Index List, Edit & Delete actions.
6. Template Scripts
6.1 Edit Template
<script id="edittemplate" type="text/x-template">
<a target="_blank" href="/LegalImaging/EditType/${Id}">Edit</a>
</script>
6.2 Delete Template
<script id="deletetemplate" type="text/x-template">
<a href="/LegalImaging/DeleteType/${Id}">Delete</a>
</script>
6.3 Type Template
<script id="typetemplate" type="text/x-template">
<a href="javascript:void(0);" class="anchorDetail" data-id=${Id}>View Indexes</a>
</script>
- Use ES6 template literals (
${Id}) to generate URLs/actions dynamically.
7. Client-Side Scripts & Event Handlers
7.1 Search Functionality
document.getElementById('Search').addEventListener('click', () => {
const val = document.getElementById('searchText').value;
const tree = document.getElementById('TreeGrid').ej2_instances[0];
tree.search(val);
});
- Plain JS hooking into Syncfusion’s
.search()API.
7.2 Modal Detail View (AJAX)
$(document).on('click', '.anchorDetail', function() {
const id = $(this).data('id');
$.ajax({
type: "GET",
url: '/LegalImaging/myModal',
data: { id },
success: data => {
$('#myModalContent').html(data);
$('#myModal').modal('show');
},
error: () => alert("Dynamic content load failed.")
});
});
- jQuery AJAX to load partial view into Bootstrap modal.
7.3 TreeGrid Load & Formatting
function load() {
const grid = document.getElementById("TreeGrid").ej2_instances[0];
grid.columns.forEach(col => {
if (col.field === "AddedDate" || col.field === "ModifiedDate") {
col.format = { type: 'date', format: 'M/d/yyyy' };
}
});
}
- Runs on TreeGrid’s
loadevent to apply date formatting.
7.4 Toolbar Export Handlers
function toolbarClick(args) {
const tree = document.getElementById("TreeGrid").ej2_instances[0];
// Excel
if (args.item.id.endsWith('_excelexport')) {
tree.excelExport({ isCollapsedStatePersist: true });
}
// PDF
else if (args.item.id.endsWith('_pdfexport')) {
tree.pdfExport({ isCollapsedStatePersist: true });
}
// CSV
else if (args.item.id.endsWith('_csvexport')) {
tree.csvExport();
}
}
- Controls export behavior, preserving collapsed state.
8. Styles
<style>
#property td div.e-checkbox-wrapper {
padding-left: 0 !important;
padding-top: 0 !important;
}
</style>
- Minor CSS tweak for Syncfusion checkbox alignment.
9. Usage Examples
- Navigate to
/LegalImaging/DocumentTypes. - Click “Add New Document Type” to open the create form.
- Use the search box to filter the grid.
- Click “View Indexes” to see child indices in a modal.
- Edit/Delete via respective action links.
- Export the grid using the top toolbar (Excel, CSV, PDF, Print).
10. UML Diagram
classDiagram
class DocumentTypeView {
+int Id
+string ImagingType
+bool IsLegal
+bool IsSafety
+bool IsIT
+IEnumerable<DocType> DocList
}
class DocType {
+int Id
+string Type
+List<DocType> Children
+string AttributeList
+string Category
+bool IsAvailable
+bool IsDeleted
+string AddedBy
+DateTime AddedDate
+string ModifiedBy
+DateTime ModifiedDate
}
DocumentTypeView --> "0..*" DocType : DocList
DocType --> "0..*" DocType : Children
11. Conclusion
This view integrates Syncfusion’s TreeGrid with ASP.NET Core MVC Razor to deliver a rich, interactive UI for managing legal imaging document types. It showcases advanced features like:
- Hierarchical data presentation
- Custom templates for actions
- Client-side searching, filtering, export
- AJAX-driven modal detail views
✨ Result: A user-friendly interface enabling Legal, Safety, and IT teams to effectively maintain document metadata in a centralized web application.