📄 DocumentAttributes.cshtml Documentation

Location: IrbyImaging/Views/AccountingImaging/DocumentAttributes.cshtml
Purpose: Renders the Index Types UI for managing Document Attributes within the Accounting Imaging module.


📚 Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. View Model & Data Model
  4. Key Functional Areas
  5. Scripts & Utilities
  6. API Endpoints Overview
  7. Usage Example
  8. 🧩 UML Class Diagram
  9. 🚀 Conclusion

🔍 Overview & Purpose

This Razor view implements an interactive data‐management page where Accounting users can:

  • Add, Edit, Delete document attributes
  • View and filter a hierarchical list of attributes
  • Export data to Excel, CSV, PDF or print it
  • Inspect related “Document Types” in a modal dialog

It leverages Syncfusion EJ2 TreeGrid, jQuery, and Bootstrap to provide a rich UI experience.


🛠️ Dependencies & Technologies

Technology / Library Usage
ASP.NET Core MVC (Razor) View templating
Syncfusion JavaScript (EJ2) TreeGrid, Button, Export
jQuery 3.6.0 AJAX, DOM manipulation
DataTables (JS) (Loaded but not used directly in this view)
Bootstrap 5 Modal dialog, layout
MetisMenu, Simplebar, Waves Theme and menu scripts
JSZip, pdfmake Client‐side export libraries

📋 View Model & Data Model

// Namespace: IrbyImaging.UI.Models
public class DocumentAttributeView
{
    public int Id { get; set; }
    public string ImagingType { get; set; }
    public bool IsLegal { get; set; }
    public bool IsSafety { get; set; }
    public bool IsIT { get; set; }
    public bool IsAccounting { get; set; }
    public bool IsBidding { get; set; }

    // Hierarchical children for TreeGrid
    public List<DocumentAttributeView> DocList { get; set; }

    // Display fields
    public string AttributeName { get; set; }
    public string TypeList { get; set; }
    public string AttrType { get; set; }
    public bool IsMultiValue { get; set; }
    public string Values { 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; }
}

🔑 Key Functional Areas

1️⃣ Add New Document Attribute Form

<form asp-action="CreateAttribute">
  @* Hidden context flags *@
  @Html.HiddenFor(m => m.ImagingType)
  @Html.HiddenFor(m => m.IsLegal)
  @* … other hidden flags … *@
  <div class="form-group">
    <input type="submit" 
           value="Add New Document Attribute" 
           class="btn btn-success irby-green" />
  </div>
</form>
  • Hidden fields preserve the current imaging‐type context.
  • Button navigates to the CreateAttribute action.

2️⃣ Syncfusion EJ2 TreeGrid

<ejs-treegrid id="TreeGrid"
    load="load"
    dataSource="Model.DocList"
    childMapping="Children"
    allowPaging="true"
    allowFiltering="true"
    allowSorting="true"
    allowExcelExport="true"
    allowPdfExport="true"
    allowReordering="true"
    toolbar="@(new[]{ "ExcelExport", "CsvExport", "PdfExport", "Print" })"
    frozenColumns="2"
    width="auto"
    height="100%">
  <e-treegrid-pagesettings pageSize="10"></e-treegrid-pagesettings>
  <e-treegrid-filtersettings type="Excel"></e-treegrid-filtersettings>
  <e-treegrid-columns>
    <e-treegrid-column field="AttributeName" headerText="Name" width="220"/>
    <e-treegrid-column field="TypeList" headerText="Document Types" template="#typetemplate" width="150"/>
    <!-- … other columns … -->
    <e-treegrid-column field="Edit" headerText="Edit/Update" template="#edittemplate" width="150"/>
    <e-treegrid-column field="Delete" headerText="Delete" template="#deletetemplate" width="150"/>
  </e-treegrid-columns>
</ejs-treegrid>
  • Hierarchical display: uses childMapping="Children" to nest.
  • Filtering/Sorting/Paging: built‐in Syncfusion features.
  • Export toolbar: Excel, CSV, PDF, Print.

3️⃣ Modal Dialog for “View Types”

<div id="myModal" class="modal">
  <div class="modal-dialog">
    <div class="modal-content">
      <div id="myModalContent"></div>
    </div>
  </div>
</div>
  • AJAX‐loaded content displays related document‑type details.

4️⃣ Search & Filtering

<input type="text" id="searchText">
<ejs-button id="Search" content="Search" cssClass="e-primary"></ejs-button>
  • Custom search triggers treegrid.search(val) on click.

5️⃣ Export & Toolbar

  • Toolbar items configured in the <ejs-treegrid> tag.
  • Custom handler toolbarClick(args) to pass isCollapsedStatePersist property.

6️⃣ Custom Templates (Edit/Delete/View)

<script id="edittemplate" type="text/x-template">
  <a target="_blank" href="/AccountingImaging/EditAttribute/${Id}">Edit</a>
</script>
<script id="deletetemplate" type="text/x-template">
  <a href="/AccountingImaging/DeleteAttribute/${Id}">Delete</a>
</script>
<script id="typetemplate" type="text/x-template">
  <a href="javascript:void(0);" class="anchorDetail" data-id=${Id}>View Types</a>
</script>
  • Syncfusion uses these for cell templates to render action links.

7️⃣ Column Formatting & Paging

  • Pagesize set to 10 via <e-treegrid-pagesettings>.
  • Date columns formatted on load (MM/dd/yyyy).

🧩 Scripts & Utilities

🔍 Search Handler

document.getElementById('Search').addEventListener('click', function () {
  var val = document.getElementById('searchText').value;
  var treegrid = document.getElementById('TreeGrid').ej2_instances[0];
  treegrid.search(val);
});

💬 AJAX Modal Loader

var TeamDetailPostBackURL = '/AccountingImaging/myModalAttribute';
$(document).on('click', '.anchorDetail', function () {
  var id = $(this).data('id');
  $.ajax({
    type: "GET",
    url: TeamDetailPostBackURL,
    data: { "id": id },
    success: function (data) {
      $('#myModalContent').html(data);
      $('#myModal').modal('show');
    },
    error: function () { alert("Dynamic content load failed."); }
  });
});

🚚 TreeGrid Load Customization

function load() {
  var treegridObj = document.getElementById("TreeGrid").ej2_instances[0];
  treegridObj.columns.forEach(col => {
    if (col.field === "AddedDate" || col.field === "ModifiedDate") {
      col.format = { type: 'date', format: 'M/d/yyyy' };
    }
  });
}

📤 Export via ToolbarClick

var collapsedStatePersist = true;
function toolbarClick(args) {
  var 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();
  }
}

🔲 GridLines Toggle

function onChange(e) {
  var treegrid = document.getElementById("TreeGrid").ej2_instances[0];
  treegrid.gridLines = e.value;
}

🔗 API Endpoints Overview

Action HTTP URL Purpose
Document Attributes Index GET /AccountingImaging/DocumentAttributes Displays the treegrid of attributes
Create New Attribute POST /AccountingImaging/CreateAttribute Handles new attribute creation
Edit Existing Attribute GET/POST /AccountingImaging/EditAttribute/{id} Renders & updates attribute details
Delete Attribute GET/POST /AccountingImaging/DeleteAttribute/{id} Soft‐deletes or permanently removes
Modal “View Types” GET /AccountingImaging/myModalAttribute Returns partial view of child types

🛠️ Usage Example

  1. Navigate to Document Attributes page.
  2. Filter by typing in the Search box & clicking Search.
  3. Export data via toolbar: click Excel, PDF, CSV or Print.
  4. Add a new attribute: click Add New Document Attribute.
  5. Edit/Delete/View Types by clicking corresponding links in the grid.

🧩 UML Class Diagram

classDiagram
    class DocumentAttributeView {
        +int Id
        +string ImagingType
        +bool IsLegal
        +bool IsSafety
        +bool IsIT
        +bool IsAccounting
        +bool IsBidding
        +List~DocumentAttributeView~ DocList
        +string AttributeName
        +string TypeList
        +string AttrType
        +bool IsMultiValue
        +string Values
        +bool IsAvailable
        +bool IsDeleted
        +string AddedBy
        +DateTime AddedDate
        +string ModifiedBy
        +DateTime ModifiedDate
    }

🚀 Conclusion

This DocumentAttributes.cshtml view provides a feature‐rich, interactive interface for managing document attributes in the Accounting Imaging module. By leveraging Syncfusion EJ2, Bootstrap, and jQuery, it offers:

  • Hierarchical data display
  • Advanced filtering, sorting, paging
  • Export capabilities
  • Inline actions (Edit/Delete/View)
  • Seamless modal dialogs

With clear separation of concerns (Razor markup, client scripts, partial‐views for modals), it is both extensible and maintainable for future enhancements.

Enjoy managing your document attributes! 😊