📄 HRImaging List View Documentation (List.cshtml)


Table of Contents

  1. Overview & Purpose
  2. Key Functional Areas
  3. Dependencies & Technologies
  4. View Model & Data Model
  5. Styles Section
  6. Main HTML Structure
  7. Document Search Form (Commented Out)
  8. Documents List Table
  9. Modals & AJAX Detail/Preview Flows
  10. Scripts Section
  11. Error Handling & Return Types
  12. Sample Usage & Code Blocks
  13. UML Diagram
  14. Conclusion

1. Overview & Purpose 🚀

List.cshtml is a Razor view in the IrbyImaging/Views/HRImaging folder. Its primary function is to:

  • Display a datatable of retrieved HR documents
  • Provide AJAX-powered modals for details and preview
  • Integrate DataTables export buttons (CSV, Excel, Print)
  • Offer links for View, Edit, and Delete operations

This helps HR teams search, view, and manage imaging documents in a rich, interactive UI.


2. Key Functional Areas 🗂️

Area Description
Model Binding @model IrbyImaging.Models.DocumentImaging binds the view to the DocumentImaging view model.
Styles Section Imports CSS for bootstrap-datepicker, DataTables, and responsive theming.
(Commented) Search Form A scaffolded form (currently commented out) for selecting a document type and retrieving indexes.
Documents List Table Renders a dynamic table when Model.ImagingList is populated.
AJAX Modals Two modals for Detail and Preview, loaded via AJAX from /HRImaging/myModalDet.
Scripts Section Loads jQuery, DataTables, DataTables buttons, Bootstrap, and custom AJAX logic.

3. Dependencies & Technologies 🔧

  • ASP.NET Core MVC Razor Pages
  • jQuery (v3.5.1)
  • DataTables (v1.10.25) + Buttons extension
  • Bootstrap (v4.x) & bootstrap-datepicker
  • MetisMenu, SimpleBar, Waves (theme utilities)
  • PDFMake, JSZip (for exporting functionalities)

4. View Model & Data Model 📑

// DocumentImaging.cs (simplified)
public class DocumentImaging {
    public int DocumentImageId { get; set; }
    public string DocumentType { get; set; }
    public List<SelectListItem> DocumentTypes { get; set; }
    public bool Preview { get; set; }
    public List<ImagingRecord> ImagingList { get; set; }
}

public class ImagingRecord {
    public int DocumentImageId { get; set; }
    public string DocumentType { get; set; }
    public List<IndexItem> IndexList { get; set; }
}

public class IndexItem {
    public string AttributeName { get; set; }
    public string IndexValue { get; set; }
}
  • DocumentTypes: Dropdown options for document types
  • ImagingList: Data source for the table, each record has dynamic indexes

5. Styles Section 🎨

Declared in @section styles:

<!-- Datepicker CSS -->
<link href="~/libs/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet">

<!-- DataTables Core & Extensions -->
<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" />

These ensure the page is responsive and features advanced table theming.


6. Main HTML Structure 🏗️

@model IrbyImaging.Models.DocumentImaging
@{ 
  ViewData["Title"] = "Documents Page"; 
  Layout = "~/Views/Shared/_Layout.cshtml"; 
}
  • Layout: Inherits a shared layout (_Layout.cshtml) for header, footer, and navigation.
  • Page Title: Set to Documents Page.

7. Document Search Form (Commented Out) 🔍

This block is currently commented out but shows how to build a search form.

@* 
<form asp-action="Search" class="form-horizontal" id="validation-form" method="post">
  @Html.HiddenFor(m => m.Preview)
  @Html.HiddenFor(m => m.DocumentImageId)
  @Html.AntiForgeryToken()
  <select asp-for="DocumentType" asp-items="@Model.DocumentTypes" class="form-control">
    <option value="" disabled selected>Select Document Type</option>
  </select>
  <button type="submit" class="btn btn-primary">Get Indexes</button>
</form>
*@

Once enabled, it would post back to HRImagingController.Search.


8. Documents List Table 📋

Renders only if Model.ImagingList has items:

@if (Model.ImagingList?.Any() == true) {
  var rec = Model.ImagingList.First();
  <table id="datatable-buttons" class="table table-striped table-bordered dt-responsive nowrap">
    <thead>
      <tr>
        <th>Document Type</th>
        @foreach (var itm in rec.IndexList) {
          <th>@itm.AttributeName</th>
        }
        <th>Details</th>
        <th>Preview</th>
        <th>View</th>
        <th>Edit</th>
        <th>Delete</th>
      </tr>
    </thead>
    <tbody>
      @foreach (var item in Model.ImagingList) {
        <tr>
          <td>@item.DocumentType</td>
          @for (int i = 0; i < item.IndexList.Count; i++) {
            <td>@item.IndexList[i].IndexValue</td>
          }
          <td><a href="javascript:void(0)" class="anchorDetail" data-id="@item.DocumentImageId">Details</a></td>
          <td><a href="javascript:void(0)" class="anchorDetail1" data-prev="preview" data-id="@item.DocumentImageId">Preview</a></td>
          <td>@Html.ActionLink("View", "ViewBlob", "HRImaging", new { id = item.DocumentImageId }, new { target = "_blank" })</td>
          <td>@Html.ActionLink("Edit", "Edit", "HRImaging", new { id = item.DocumentImageId }, new { target = "_blank" })</td>
          <td>@Html.ActionLink("Delete", "DeleteUploadedDocument", "HRImaging", new { id = item.DocumentImageId }, new { target = "_blank" })</td>
        </tr>
      }
    </tbody>
  </table>
}
  • Dynamic Columns: Reflects all IndexList attributes.
  • CRUD Links: Uses ActionLink for ViewBlob, Edit, and DeleteUploadedDocument.

9. Modals & AJAX Detail/Preview Flows 🔄

Two jQuery-driven modals fetch HTML from /HRImaging/myModalDet:

var TeamDetailPostBackURL = '/HRImaging/myModalDet';

// Details Modal
$('.anchorDetail').click(function() {
  var id   = $(this).data('id');
  $.get(TeamDetailPostBackURL, { id: id, preview: '' })
    .done(data => {
      $('#myModalContent').html(data);
      $('#myModal').modal('show');
    })
    .fail(() => alert('Dynamic content load failed.'));
});

// Preview Modal
$('.anchorDetail1').click(function() {
  var id   = $(this).data('id');
  var prev = true;
  $.get(TeamDetailPostBackURL, { id: id, Preview: prev })
    .done(data => {
      $('#myModalContent').html(data);
      $('#myModal').modal('show');
    })
    .fail(() => alert('Dynamic content load failed.'));
});
  • myModal container is reused for both flows.
  • Server Endpoint: HRImagingController.myModalDet(int id, bool preview)

10. Scripts Section 🎯

@section scripts {
  <!-- jQuery & DataTables -->
  <script src="https://code.jquery.com/jquery-3.5.1.js"></script>
  <script src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script>
  <script src="https://cdn.datatables.net/buttons/1.7.1/js/dataTables.buttons.min.js"></script>
  <script src="~/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
  <!-- ... additional libs ... -->

  <!-- Initialize DataTable with export buttons -->
  <script>
    $(document).ready(function() {
      $('#datatable-buttons').DataTable({
        dom: 'Bfrtip',
        processing: true,
        filter: true,
        buttons: ['csv', 'excel', 'print']
      });
    });
  </script>
}
  • DataTable Init: Enables CSV, Excel, Print on top of the table.
  • Third-party: PDFMake, JSZip loaded for full button support.

11. Error Handling & Return Types 🚨

  • AJAX Errors: Trigger alert("Dynamic content load failed.").
  • Server Return: Partial View HTML injected into the modal.
  • HTTP Methods: GET for detail & preview, POST for (commented) search.

12. Sample Usage & Code Blocks 💡

Rendering the View

public IActionResult List() {
  var model = new DocumentImaging {
    DocumentTypes = _service.GetDocumentTypes(),
    ImagingList   = _service.GetAllImagingRecords()
  };
  return View(model);
}

Controller Endpoint for Modal

public IActionResult myModalDet(int id, bool preview = false) {
  var record = _service.GetImagingById(id);
  return PartialView("_ImagingDetailPartial", new ImagingDetailViewModel {
    Record  = record,
    Preview = preview
  });
}

13. UML Diagram 📐

+--------------------+      1    *      +----------------+
| DocumentImaging    |<>-------------->| ImagingRecord  |
|--------------------|                  |----------------|
| - DocumentImageId  |                  | - DocumentImageId |
| - DocumentType     |                  | - DocumentType     |
| - DocumentTypes    |                  | - IndexList    *   |
| - Preview          |                  +----------------+
| - ImagingList[*]   |
+--------------------+
        |
        | 1..*
        v
+----------------+
| IndexItem      |
|----------------|
| - AttributeName|
| - IndexValue   |
+----------------+

14. Conclusion ✅

The List.cshtml view provides a robust, user-friendly interface for HR document imaging:

  • Dynamic columns based on metadata
  • Rich DataTables features with export options
  • AJAX modals for seamless detail and preview experiences
  • CRUD integration via action links

By following this documentation, developers can customize, extend, or integrate this view in larger ASP.NET Core MVC applications with ease. Happy coding! 🎉