📄 Documentation: SearchResults.cshtml (Legal Dashboard – Search Results View)
📑 Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- MVC Structure & Models
- Key Functional Areas
- Razor Syntax & HTML Markup
- JavaScript & Interactivity
- CSS Styling & Responsiveness
- API Endpoints Overview
- UML Class Diagram
- Usage Example
- Conclusion
🔎 Overview & Purpose
SearchResults.cshtml is the Razor View under IrbyImaging/Views/LegalImaging that displays the results of a document search on the Legal Dashboard. It provides:
- A search form for entering filter criteria (handled by the
Searchaction). - A data grid (powered by DataTables) to list matching documents.
- View/Edit/Delete action links for each document.
- Dynamic row styling to highlight documents nearing or past their expiration date.
- A spinner feedback during asynchronous operations.
This page leverages server‐side data (model: IrbyImaging.Models.DocumentImaging) and rich client‐side functionality for an interactive user experience.
🔧 Dependencies & Technologies
| Category | Libraries / Frameworks |
|---|---|
| Front‑end Frameworks | Bootstrap 4, jQuery |
| Data Grid | DataTables + Buttons Extension |
| Date Picker | Bootstrap‑datepicker |
| Charts & Spinner | ApexCharts, Google Charts, Spin.js |
| Syncfusion Integration | Syncfusion.EJ2, Syncfusion.JavaScript.Models |
| Server‑Side | ASP.NET Core MVC, Razor Syntax |
| CSS Utilities | MetisMenu, SimpleBar, Waves |
🏗 MVC Structure & Models
1. View Model: DocumentImaging
public class DocumentImaging
{
public bool Preview { get; set; }
public int DocumentImageId { get; set; }
public List<DocumentImageViewModel> ImagingList { get; set; }
}
2. Child Model: DocumentImageViewModel
public class DocumentImageViewModel
{
public int DocumentImageId { get; set; }
public string DocumentType { get; set; }
public string FileName { get; set; }
public List<IndexViewModel> IndexList { get; set; }
}
3. Index Item: IndexViewModel
public class IndexViewModel
{
public string AttributeName { get; set; }
public string IndexValue { get; set; }
}
🔑 Key Functional Areas
4.1 Form Initialization & Data Binding
-
Razor Directive binds the view to the
DocumentImagingmodel:@model IrbyImaging.Models.DocumentImaging -
Hidden fields store state (
Preview,DocumentImageId). -
Anti‑forgery Token and ValidationSummary ensure form security and display of model errors:
@Html.HiddenFor(m => m.Preview) @Html.HiddenFor(m => m.DocumentImageId) @Html.AntiForgeryToken() @Html.ValidationSummary(true, "", new { @class = "text-danger" })
4.2 Document List Rendering
- Checks if
Model.ImagingListexists and has entries:@if (Model.ImagingList?.Any() == true) { // Render table } else { <h2>No Search Results Found</h2> } - Each document row displays:
- Document Type
- File Name
- Index Attributes (dynamic columns)
- Action Links: View, Edit, Delete
@foreach (var item in Model.ImagingList)
{
<tr>
<td>@Html.DisplayFor(m => item.DocumentType)</td>
<td>@Html.DisplayFor(m => item.FileName)</td>
@for (int i = 0; i < item.IndexList.Count; i++)
{
<td class="indexSearch">
(@Html.DisplayFor(_ => item.IndexList[i].AttributeName))
@Html.DisplayFor(_ => item.IndexList[i].IndexValue)
</td>
}
<td>@Html.ActionLink("View", "ViewDoc", new { id = item.DocumentImageId }, new { target = "_blank" })</td>
<td>@Html.ActionLink("Edit", "Edit", new { id = item.DocumentImageId }, new { target = "_blank" })</td>
<td>@Html.ActionLink("Delete", "DeleteUploadedDocument", new { id = item.DocumentImageId }, new { target = "_blank" })</td>
</tr>
}
4.3 DataTables Integration & Button Configuration
-
CSS Includes for DataTables:
<link href="~/libs/datatables.net-bs4/css/dataTables.bootstrap4.min.css" rel="stylesheet" /> <link href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.min.css" rel="stylesheet" /> <link href="https://cdn.datatables.net/buttons/1.7.1/css/buttons.dataTables.min.css" rel="stylesheet" /> -
JavaScript Includes:
<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="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script> <script src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.html5.min.js"></script> <script src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.print.min.js"></script> -
Initialization with Export Buttons:
$('#datatable-buttons').DataTable({ dom: 'Bfrtip', buttons: ['csv', 'excel', 'print'], processing: true, filter: true, fnCreatedRow: applyExpirationStyling });
4.4 Row Highlighting (Expired & Warnings)
- Logic inside
fnCreatedRowcallback:- Parse the Expiration Date from the
.indexSearchcell. - Compute days difference vs. current date.
- Add CSS classes based on thresholds:
- Parse the Expiration Date from the
| Days Difference | CSS Class | Meaning |
|---|---|---|
| ≤ 0 | expired |
Already expired 🚨 |
| 1 – 30 | expiresSoon |
Expires within 30 days ⚠️ |
| 31 – 90 | expireWarning |
Expires within 90 days 🔔 |
function applyExpirationStyling(nRow, aData, iDataIndex) {
var $row = $(nRow);
var text = $row.find('.indexSearch').text().toLowerCase();
if (text.includes('expiration date')) {
// ... parse date & compute days
if (days <= 0) $row.addClass('expired');
else if (days <= 30) $row.addClass('expiresSoon');
else if (days <= 90) $row.addClass('expireWarning');
}
}
4.5 Loading Spinner & User Feedback
-
Spin.js integration to show a spinner when the “Search” button (
#openSearch) is clicked:$("#openSearch").click(function() { $("#loading").fadeIn(); var opts = { lines: 19, length: 28, width: 7, scale: 0.05, color: '#11467e', animation: 'spinner-line-shrink' }; var spinner = new Spinner(opts).spin(document.getElementById('loading')); });
📝 Razor Syntax & HTML Markup
-
Layout & Title:
@{ ViewData["Title"] = "Legal Dashboard"; Layout = "~/Views/Shared/_LegalLayout.cshtml"; } -
Sectioned Styles & Scripts using
@section styles { ... }and@section scripts { ... }.
📜 JavaScript & Interactivity
- Event Hooks:
- DataTables init on
#datatable-buttons&#datatable-buttons2. - Click event on
#openSearchto show spinner.
- DataTables init on
- Commented Blocks show potential AJAX calls for modals, autocomplete, dynamic partial loads—ready for future enhancement.
🎨 CSS Styling & Responsiveness
.searchSection { display: flex; /* Responsive flex-container */ }
@media (max-width: 800px) {
.searchSection { flex-direction: column; }
}
.footerPosition { position: absolute !important; }
#indexSearch td div.e-checkbox-wrapper { padding: 0 !important; }
.expired { background-color: #f8d7da !important; } /* Red tint */
.expiresSoon { background-color: #fff3cd !important; } /* Yellow tint */
.expireWarning { background-color: #d1ecf1 !important; } /* Light blue tint */
- Responsive adjustments for mobile devices.
🔗 API Endpoints Overview
| Action | HTTP Method | Route | Purpose |
|---|---|---|---|
| Search | POST | /LegalImaging/Search |
Submits search criteria |
| ViewDoc | GET | /LegalImaging/ViewDoc/{id} |
Opens document preview in new tab |
| Edit | GET/POST | /LegalImaging/Edit/{id} |
Loads edit form / saves changes |
| DeleteUploadedDocument | GET/POST | /LegalImaging/DeleteUploadedDocument/{id} |
Deletes selected document |
| PreLoadFormDataBasedOnDropdown* | GET | /LegalImaging/PreLoadFormDataBasedOnDropdown?DocumentType=… |
Partial form load based on DocType |
| myModalDet* | GET | /LegalImaging/myModalDet?id=&preview= |
Loads detail modal via AJAX |
* = commented out, available for future enhancements
🔲 UML Class Diagram
@startuml
class DocumentImaging {
+ bool Preview
+ int DocumentImageId
+ List<DocumentImageViewModel> ImagingList
}
class DocumentImageViewModel {
+ int DocumentImageId
+ string DocumentType
+ string FileName
+ List<IndexViewModel> IndexList
}
class IndexViewModel {
+ string AttributeName
+ string IndexValue
}
DocumentImaging "1" --> "*" DocumentImageViewModel
DocumentImageViewModel "1" --> "*" IndexViewModel
@enduml
▶️ Usage Example
- Controller Action:
[HttpPost] [ValidateAntiForgeryToken] public IActionResult Search(DocumentImaging model) { // Populate model.ImagingList based on search criteria return View("SearchResults", model); } - Invoke via the Legal Dashboard menu or form submit:
<button id="openSearch" type="submit" class="btn btn-primary">Search</button> <div id="loading" style="display:none;"></div> - Result: the view loads a styled, interactive table with export capabilities.
✅ Conclusion
The SearchResults.cshtml view brings together server-side Razor data binding and client-side libraries (DataTables, Spin.js, Bootstrap) to create a robust, user-friendly document search interface for the Legal Imaging module. Key features include:
- Dynamic data grid with export buttons
- Expiration‐based row highlights
- Action links for CRUD operations
- Responsive design for mobile compatibility
- Ready‐to‐use AJAX hooks for future enhancements
🎉 With this documentation, developers can easily understand, maintain, and extend the Legal Imaging search results page!