📄 Document Attributes View Documentation
File: IrbyImaging/Views/LegalImaging/DocumentAttributes.cshtml
Purpose: Provide a tree‑grid UI to list, search, export, and manage document attributes in the Legal Imaging module.
🗂 Table of Contents
- Overview & Purpose
- File Structure & Path
- Dependencies & Technologies
- View Model
- Layout & Title Configuration
- UI Structure
- JavaScript & Event Handlers
- API Endpoints Overview
- Usage Example
- UML Diagram
- Conclusion
🔍 1. Overview & Purpose
This Razor view renders an interactive TreeGrid of document attributes specific to legal imaging. It allows users to:
- List attributes in a hierarchical structure
- Search, sort, filter, and page through entries
- Export data (Excel, CSV, PDF, Print)
- Create, Edit, Delete attributes
- View child types in a modal dialog
🗄 2. File Structure & Path
IrbyImaging/
└─ Views/
└─ LegalImaging/
└─ DocumentAttributes.cshtml
🔗 3. Dependencies & Technologies
| Category | Libraries & Frameworks |
|---|---|
| Server‑Side | ASP.NET Core MVC, Razor Views |
| Client‑Side Grid | Syncfusion EJ2 TreeGrid (ejs-treegrid) |
| AJAX & DOM | jQuery 3.6.0 |
| Data Export | DataTables Buttons, JSZip, pdfmake |
| UI & Layout | Bootstrap 5, MetisMenu, SimpleBar, Node‑Waves |
| Styling | Custom CSS, Bootstrap |
📦 4. View Model
@model IrbyImaging.UI.Models.DocumentAttributeView
DocumentAttributeView must contain at least:
IEnumerable<DocumentAttributeDto> DocList– the tree data- Flags / hidden props:
ImagingType,IsLegal,IsSafety,IsIT,Id
🏗 5. Layout & Title Configuration
@{
ViewBag.Title = "Index Types";
ViewBag.pTitle = "Index Types";
ViewBag.pageTitle = "Index Types";
Layout = "~/Views/Shared/_LegalLayout.cshtml";
}
<h2>Index Types</h2>
- Layout: Uses a shared legal layout (
_LegalLayout.cshtml). - ViewBag props set dynamic page titles.
🖥 6. UI Structure
6.1 Add New Document Attribute Form
<div class="col-lg-2">
<form asp-action="CreateAttribute">
@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 Attribute" class="btn btn-success irby-green"/>
</form>
</div>
- asp-action: posts to
LegalImaging/CreateAttribute. - Hidden fields preserve context flags.
6.2 TreeGrid Component
<ejs-treegrid id="TreeGrid"
dataSource="Model.DocList"
childMapping="Children"
treeColumnIndex="0"
allowPaging="true"
allowFiltering="true"
allowSorting="true"
allowReordering="true"
toolbar="@(new List<string>() {
"ExcelExport","CsvExport","PdfExport","Print"
})">
<e-treegrid-pagesettings pageSize="10"/>
<e-treegrid-filtersettings type="Excel"/>
<e-treegrid-columns>
<e-treegrid-column field="AttributeName" headerText="Name" width="220"/>
<e-treegrid-column field="AttrType" headerText="Data Type" width="150"/>
<e-treegrid-column field="IsMultiValue" headerText="Is MultiValue" width="150"/>
<!-- … other columns … -->
<e-treegrid-column field="Edit" headerText="Edit" template="#edittemplate"/>
<e-treegrid-column field="Delete" headerText="Delete" template="#deletetemplate"/>
</e-treegrid-columns>
</ejs-treegrid>
childMapping="Children": property name for child nodes.- Export buttons wired into
toolbarClickJS handler.
6.3 Detail Modal
<div id='myModal' class='modal'>
<div class="modal-dialog">
<div class="modal-content">
<div id='myModalContent'></div>
</div>
</div>
</div>
- Populated dynamically via AJAX when View Types link is clicked.
⚙️ 7. JavaScript & Event Handlers
7.1 Search Functionality
document.getElementById('Search').addEventListener('click', () => {
const val = document.getElementById('searchText').value;
const treegrid = document.getElementById('TreeGrid').ej2_instances[0];
treegrid.search(val);
});
- Binds on‑click to perform TreeGrid search.
7.2 Modal AJAX Load
const TeamDetailPostBackURL = '/LegalImaging/myModalAttribute';
$(document).on('click', '.anchorDetail', function() {
const id = $(this).data('id');
$.get(TeamDetailPostBackURL, { id }, html => {
$('#myModalContent').html(html);
$('#myModal').modal('show');
}).fail(() => alert("Dynamic content load failed."));
});
- Calls controller action
myModalAttribute(id)to fetch partial view.
7.3 TreeGrid Export & Toolbar Click
let collapsedStatePersist = true;
function toolbarClick(args) {
const grid = document.getElementById("TreeGrid").ej2_instances[0];
if (args.item.id.endsWith('_excelexport')) {
grid.excelExport({ isCollapsedStatePersist: collapsedStatePersist });
} else if (args.item.id.endsWith('_pdfexport')) {
grid.pdfExport({ isCollapsedStatePersist: collapsedStatePersist });
} else if (args.item.id.endsWith('_csvexport')) {
grid.csvExport();
}
}
function onChange(args) {
collapsedStatePersist = !!args.checked;
}
- Supports Excel, PDF, CSV exports, preserving collapse state.
7.4 Date Formatting on Load
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' };
}
});
}
- Applies date formats dynamically.
🔌 8. API Endpoints Overview
| Action | Route | HTTP Verb | Description |
|---|---|---|---|
| Create Document Attribute | /LegalImaging/CreateAttribute |
POST | Launches “Add New” page/form. |
| Edit Attribute | /LegalImaging/EditAttribute/{id} |
GET/POST | Retrieves & updates an attribute. |
| Delete Attribute | /LegalImaging/DeleteAttribute/{id} |
GET/POST | Confirms & deletes an attribute. |
| Modal Detail | /LegalImaging/myModalAttribute?id={id} |
GET | Returns partial view of child types. |
🎯 9. Usage Example
- Navigate to
/LegalImaging/DocumentAttributesin your browser. - Click “Add New Document Attribute” to define a new field.
- Search by name or type using the search box.
- Filter/Sort columns via dropdowns in each header.
- Export using toolbar icons (Excel, CSV, PDF, Print).
- View Types in a modal by clicking the link in the “Document Types” column.
- Edit/Delete entries via the corresponding templates.
📈 10. UML Diagram
+--------------------------------+
| DocumentAttributeView |
|--------------------------------|
| - IEnumerable<Dto> DocList |
| - int ImagingType |
| - bool IsLegal, IsSafety, IsIT |
| - int Id |
+--------------------------------+
| 1..*
v
+-------------------+
| DocumentAttributes|
| (Razor View) |
+-------------------+
| - TreeGrid |
| - Modal |
| - JS Handlers |
+-------------------+
🏁 11. Conclusion
This view delivers a full-featured interface for managing Legal Imaging document attributes. Leveraging Syncfusion’s TreeGrid, jQuery, and AJAX, it provides an intuitive, actionable UI—complete with search, filtering, export, and CRUD operations. Integrate it in your MVC pipeline by wiring up the corresponding controller actions and model DTOs, and customizing the hidden flags (IsLegal, etc.) to suit your domain logic.
🚀 Happy Imaging!