š IrbyImaging/Views/Imaging/List.cshtml Documentation
Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- MVC Integration
- ViewModel & DataModel
- Key Functional Areas
5.1. Page Metadata & Styles
5.2. Search Form (Html.BeginForm)
5.3. Syncfusion EJ2Ā TreeGrid Configuration
5.4. ClientāSide Templates for Actions
5.5. JavaScript Event Handlers & Utilities - API Endpoints Overview
- ThirdāParty Integrations
- Sample Code Blocks & Usage Examples
- UML Diagrams
- Conclusion
1. Overview & Purpose
List.cshtml is an ASP.NET Core MVC Razor View under the IrbyImaging area responsible for:
- š Rendering a rich search form for filtering document records.
- š Displaying results in a featureārich TreeGrid (Syncfusion EJ2).
- š¤ Enabling client-side actions: Search, Export (Excel/PDF/CSV), Print, View/Edit/Delete, and modal previews.
This page serves endāusers (e.g., site administrators) who need to search, view, and manage imaging documents.
2. Dependencies & Technologies
| Category | Libraries / Frameworks |
|---|---|
| FrontāEnd Frameworks | BootstrapĀ 5, jQuery |
| JavaScript Components | Syncfusion EJ2 (TreeGrid, Button, DialogUtility, etc.) |
| Date Picker | bootstrapādatepicker |
| DataTables (CSS Only) | DataTables.net (Bootstrap 4 styles) |
| ASP.NET Core MVC | Razor Views, Html Helpers, AntiForgery |
3. MVC Integration
- Model Declaration
@model IrbyImaging.Models.DocumentImaging - Controller Action
public IActionResult List(DocumentImaging model) { // Populate model.ImgResults based on search criteria return View(model); } - Layout
Layout = "~/Views/Shared/_Layout.cshtml"; ViewData["Title"] = "Documents Page";
4. ViewModel & DataModel
public class DocumentImaging {
public bool Preview { get; set; }
public IEnumerable<DocumentImageResult> ImgResults { get; set; }
// ... other search fields like DocumentType, JobDate, etc.
}
public class DocumentImageResult {
public int DocumentImageId { get; set; }
public string DocumentType { get; set; }
public DateTime JobDate { get; set; }
public string JobNumber { get; set; }
// ... additional fields: JobName, UnitNumber, BlobName, etc.
public List<DocumentImageResult> Children { get; set; }
}
Preview: Flag to indicate if modal should show a preview.ImgResults: Hierarchical data source for the TreeGrid.
5. Key Functional Areas
5.1. Page Metadata & Styles
@section styles {
<!-- Datepicker -->
<link href="~/libs/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet">
<!-- DataTables CSS -->
<link href="~/libs/datatables.net-bs4/css/dataTables.bootstrap4.min.css" rel="stylesheet">
<link href="~/libs/datatables.net-buttons-bs4/css/buttons.bootstrap4.min.css" rel="stylesheet">
<link href="~/libs/datatables.net-responsive-bs4/css/responsive.bootstrap4.min.css" rel="stylesheet">
}
- Purpose: Import CSS for dateāpicker & table enhancements.
5.2. Search Form (Html.BeginForm)
@using (Html.BeginForm()) {
@Html.HiddenFor(m => m.Preview)
@Html.AntiForgeryToken()
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="card">
<div class="card-body">
<h4 class="card-title mb-4">View Documents</h4>
<div data-repeater-list="outer-group" class="outer">
<div data-repeater-item class="outer">
<!-- Document Type -->
<label class="col-md-2 col-form-label">Document Type</label>
<div class="col-md-4">
<select name="DocumentType" class="form-select">
<option>Select Type</option>
<option>ANNUAL CRANE INSPECT REP</option>
<!-- ⦠other options ⦠-->
</select>
</div>
<!-- Document Category -->
<label class="col-form-label col-lg-2">Document Category</label>
<div class="col-md-4">
<input type="text" class="form-control" name="DocumentCategory" placeholder="Document Category" />
</div>
</div>
<!-- More filter rows (Job Date, Job Number, Job Name, etc.) -->
</div>
<div class="row float-left">
<button type="submit" class="btn btn-primary">Search Documents</button>
</div>
</div>
</div>
}
- Repeater: Allows multiple filter groups (if needed).
- Fields: DocumentType, DocumentCategory, DocumentDate (with datepicker), JobNumber, JobName, JobOwner, UnitNumber, DocumentNotes, WorkOrder, CompletedBy.
5.3. Syncfusion EJ2 TreeGrid Configuration
<ejs-treegrid
id="TreeGrid"
dataSource="Model.ImgResults"
childMapping="Children"
showColumnMenu="true"
allowReordering="true"
allowFiltering="true"
allowSorting="true"
allowTextWrap="true"
allowPaging="true"
width="100%"
height="100%"
toolbar="@(
new List<string>() {
"ExcelExport", "CsvExport", "PdfExport", "Print"
})"
toolbarClick="toolbarClick"
allowExcelExport="true"
allowPdfExport="true">
<e-treegrid-pagesettings pageSize="15"></e-treegrid-pagesettings>
<e-treegrid-filtersettings type="Excel"></e-treegrid-filtersettings>
<e-treegrid-columns>
<e-treegrid-column field="DocumentType" headerText="Type" width="200"></e-treegrid-column>
<e-treegrid-column field="JobNumber" headerText="Job#" textAlign="Center" width="140"></e-treegrid-column>
<!-- ā¦more columns⦠-->
<e-treegrid-column field="BlobName" headerText="View" template="#viewtemplate" width="120"></e-treegrid-column>
<e-treegrid-column field="Edit" headerText="Edit" template="#edittemplate" width="120"></e-treegrid-column>
<e-treegrid-column field="Delete" headerText="Delete" template="#deletetemplate" width="120"></e-treegrid-column>
</e-treegrid-columns>
</ejs-treegrid>
- Features Enabled
⢠Sorting / Filtering / Paging / Reordering / Export - Templates
Custom templates for View, Edit, Delete actions (see next section).
5.4. ClientāSide Templates for Actions
<script id="viewtemplate" type="text/x-template">
<a target="_blank" href="/Imaging/ViewBlob/${DocumentImageId}">View</a>
</script>
<script id="edittemplate" type="text/x-template">
<a target="_blank" href="/Imaging/Edit/${DocumentImageId}">Edit</a>
</script>
<script id="deletetemplate" type="text/x-template">
<a target="_blank" href="/Imaging/DeleteUploadedDocument/${DocumentImageId}">Delete</a>
</script>
- Usage: Injects action links into each rowādynamic placeholders (
${DocumentImageId}).
5.5. JavaScript Event Handlers & Utilities
- Search Box
document.getElementById('Search').addEventListener('click', function () { var val = document.getElementById('searchText').value; var tg = document.getElementById('TreeGrid').ej2_instances[0]; tg.search(val); }); - Export Toolbar Click
function toolbarClick(args) { var tree = document.getElementById("TreeGrid").ej2_instances[0]; if(args.item.id.endsWith('_excelexport')) { tree.excelExport({ isCollapsedStatePersist: true }); } else if(args.item.id.endsWith('_pdfexport')) { tree.pdfExport({ isCollapsedStatePersist: true }); } else if(args.item.id.endsWith('_csvexport')) { tree.csvExport(); } } - Modal Preview (AJAX)
$(".anchorDetail").click(function () { $.ajax({ type: "GET", url: '/Imaging/myModal', data: { id: $(this).data('id'), preview: $(this).data('prev') }, success: function (data) { $('#myModalContent').html(data); $('#myModal').modal('show'); } }); }); - Column Formatting on Load
function load() { var tree = document.getElementById("TreeGrid").ej2_instances[0]; tree.columns.forEach(col => { if(col.field === "JobDate") col.format = { type: 'date', format: 'M/d/yyyy' }; }); }
6. API Endpoints Overview
| Endpoint | HTTP | Description |
|---|---|---|
/Imaging/List |
GET/POST | Renders List.cshtml, binds DocumentImaging model. |
/Imaging/ViewBlob/{id} |
GET | Streams PDF/Image blob for viewing. |
/Imaging/Edit/{id} |
GET | Returns edit form for document metadata. |
/Imaging/DeleteUploadedDocument/{id} |
GET | Deletes a document by its ID. |
/Imaging/myModal |
GET | Returns partial view for modal content. |
/Imaging/GetNames |
GET | (Commented) Autocomplete source for DocumentType. |
7. ThirdāParty Integrations
- Syncfusion EJ2 ā Advanced TreeGrid & Buttons with exporting, filtering, sorting.
- Bootstrap Datepicker ā
<input type="text" data-provide="datepicker">. - DataTables ā (CSS only) for alternative tabular styling.
- jQuery AJAX ā Loading modal content dynamically.
8. Sample Code Blocks & Usage Examples
8.1. Triggering an Excel Export
<ejs-treegrid toolbar="@(new List<string>{ "ExcelExport" })" toolbarClick="toolbarClick"></ejs-treegrid>
function toolbarClick(args) {
if (args.item.id.includes('excelexport')) {
var grid = document.getElementById('TreeGrid').ej2_instances[0];
grid.excelExport({ isCollapsedStatePersist: true });
}
}
8.2. AJAXāLoaded Modal
<a class="anchorDetail1" data-id="@item.Id" data-prev="True">Quick Preview</a>
$('.anchorDetail1').click(function() {
var id = $(this).data('id');
$.get('/Imaging/myModal', { id, preview: true })
.done(data => {
$('#myModalContent').html(data);
$('#myModal').modal('show');
});
});
9. UML Diagrams
9.1. Sequence Diagram
sequenceDiagram
participant User
participant View as List.cshtml
participant Controller as ImagingController
participant Modal
User->>View: Click "Search Documents"
View->>Controller: POST /Imaging/List (form data)
Controller-->>View: Return filtered DocumentImaging model
View->>TreeGrid: Render ImgResults
User->>View: Click "View"
View->>Controller: GET /Imaging/ViewBlob/{id}
Controller-->>User: Blob stream
9.2. Class Diagram
classDiagram
class DocumentImaging {
+bool Preview
+IEnumerable~DocumentImageResult~ ImgResults
+string DocumentType
+DateTime DocumentDate
+string JobNumber
// ... other search fields
}
class DocumentImageResult {
+int DocumentImageId
+string DocumentType
+DateTime JobDate
+string JobNumber
+List~DocumentImageResult~ Children
}
DocumentImaging --> DocumentImageResult : contains >
10. Conclusion
This List.cshtml Razor view provides a comprehensive interface for searching, viewing, editing, and exporting imaging documents. Leveraging Syncfusion EJ2 and Bootstrap, it delivers a modern, responsive, and featureārich experience. Its modular JavaScript handlers, AJAXāloaded modals, and MVC conventions ensure maintainability and extensibility for future enhancements. š
Happy coding & efficient document management! š