📋 Documentation: IrbyImaging/Views/Computers/Index.cshtml


Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. View Models & Data Models
  4. Key Functional Areas
  5. Razor Markup Structure
  6. Syncfusion TreeGrid Configuration
  7. Client‑Side Scripts & Events
  8. Styling & CSS Customizations
  9. Sample Usage & Screenshots
  10. UML Class Diagram
  11. Conclusion

1. Overview & Purpose 🚀

This Razor view (Index.cshtml) is part of the IrbyImaging ASP.NET Core MVC application. It renders a comprehensive, interactive listing of Computers in the system, allowing users to:

  • Add new computers
  • Filter & search by status or free‑text
  • Sort, page, and export the grid (Excel, CSV, PDF, Print)
  • Quickly navigate to Details, Edit, or Delete operations

Intent: Provide IT administrators an at‑a‑glance, fully featured asset management interface.


2. Dependencies & Technologies 🔧

Technology / Library Purpose
ASP.NET Core MVC Razor View templating
Syncfusion.EJ2 (ejs-treegrid) Rich data grid with hierarchy support
Syncfusion.JavaScript.Models Config objects for Syncfusion controls
Font Awesome (fa fa-search) Iconography
Bootstrap 4 (.row, .card) Layout & styling
jQuery / Vanilla JS Event handling & DOM manipulation
@using Syncfusion.JavaScript
@using Syncfusion.JavaScript.Models
@using Syncfusion.EJ2

3. View Models & Data Models 📦

ComputerListViewModel

namespace IrbyImaging.Models
{
    public class ComputerListViewModel
    {
        public AssetStatus Status { get; set; }
        public IEnumerable<Computer> Computers { get; set; }
    }
}
  • Status: AssetStatus enum (e.g., Active, Retired).
  • Computers: Collection of Computer domain models.

Computer (Sample)

Property Type Description
Id Guid / int Unique identifier
MakeAndModel string e.g., “Dell Latitude 7490”
OperatingSystem string e.g., “Windows 10 Pro”
SerialNumber string Service tag or SN
AssetNumber string JDE asset tag
CpsNumber string CPS assignment number
EmployeeId string Assigned employee’s ID
OwnerFullName string Assigned employee’s full name
PurchaseDate DateTime Date of purchase
EndOfWarranty DateTime Warranty expiration date
Status AssetStatus Current asset status
NeedsReview bool Flag for IT review needed

4. Key Functional Areas 🏷️

  1. Header & Actions

    • Add New Computer button
    • Status‑based heading with a count
  2. Filtering & Searching

    • Drop‑down to filter by AssetStatus
    • Free‑text search input
  3. Data Presentation

    • Syncfusion TreeGrid with:
      • Column reordering, filtering, sorting
      • Paging (15 items per page)
      • Hierarchical (childMapping) support
      • Excel/CSV/PDF export & Print
  4. Row‑Level Actions

    • Details, Edit, Delete templates via <script type="text/x-template">
  5. Client‑Side Logic

    • load() formats date columns
    • toolbarClick() handles export logic
    • Custom search button wires into TreeGrid’s .search()

5. Razor Markup Structure 🔍

@model IrbyImaging.Models.ComputerListViewModel
@{
    ViewData["Title"] = "Computer List";
    Layout = "~/Views/Shared/_ATSLayout.cshtml";
}
<div class="row">
  <div class="col-lg-2">
    <a asp-action="Create" class="btn btn-success irby-green">Add New Computer</a>
  </div>
  ...
</div>

<!-- Search Form -->
<div class="row" style="float:right;">
  <form asp-action="Index" method="get">
    <div class="input-group">
      <input type="text" name="search" class="form-control" placeholder="Search for..." />
      <div class="col-lg-4" style="float:right;">
        @Html.DropDownListFor(
            m => m.Status,
            Html.GetEnumSelectList<IrbyImaging.Utility.AssetStatus>(),
            new { @class = "form-control dropdown" })
      </div>
      <span class="input-group-addon">
        <button type="submit" class="btn btn-primary irby-blue">
          <i class="fa fa-search"></i> Search
        </button>
      </span>
    </div>
  </form>
</div>

<h2>
  @Html.DisplayFor(m => m.Status) Computers
  <span style="color:blue">@Model.Computers.Count()</span>
</h2>

6. Syncfusion TreeGrid Configuration 📊

<ejs-treegrid
  id="TreeGrid"
  load="load"
  dataSource="ViewBag.dataSource"
  childMapping="Children"
  showColumnMenu="true"
  allowReordering="true"
  allowFiltering="true"
  allowSorting="true"
  allowTextWrap="true"
  allowPaging="true"
  toolbar="@(new List<string> { "ExcelExport", "CsvExport", "PdfExport", "Print" })"
  allowExcelExport="true"
  allowPdfExport="true"
  gridLines="Both"
  width="100%"
  height="100%">
  
  <e-treegrid-pagesettings pageSize="15"></e-treegrid-pagesettings>
  <e-treegrid-filtersettings type="Excel"></e-treegrid-filtersettings>
  
  <e-treegrid-columns>
    <e-treegrid-column field="MakeAndModel" headerText="Make/Model" width="160"></e-treegrid-column>
    <!-- more columns... -->
    <e-treegrid-column field="Details" headerText="Details" template="#detailtemplate" width="120"></e-treegrid-column>
    <e-treegrid-column field="Update" 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>

Highlights

  • dataSource is provided by the controller via ViewBag.dataSource.
  • childMapping="Children" enables hierarchical display if a computer has “child” assets.
  • Templates (#detailtemplate, #edittemplate, #deletetemplate) generate action links.

7. Client‑Side Scripts & Events 📑

Search Button Handler

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

Date Formatting on Load

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

Export Toolbar Logic

function toolbarClick(args) {
  var treeGridObj = document.getElementById("TreeGrid").ej2_instances[0];
  if (args.item.id.endsWith('_excelexport')) {
    treeGridObj.excelExport({ isCollapsedStatePersist: true });
  } else if (args.item.id.endsWith('_pdfexport')) {
    treeGridObj.pdfExport({ isCollapsedStatePersist: true });
  } else if (args.item.id.endsWith('_csvexport')) {
    treeGridObj.csvExport();
  }
}

8. Styling & CSS Customizations 🎨

#property td div.e-checkbox-wrapper {
  padding-left: 0 !important;
  padding-top: 0 !important;
}
.irby-green { background-color: #28a745; }
.irby-blue  { background-color: #007bff; }
  • Card layout via Bootstrap.
  • Custom classes (.irby-green, .irby-blue) for button themes.

9. Sample Usage & Screenshots 📸

  1. Navigate to /Computers/Index
  2. View all computers, filter by status, or search by serial/asset.
  3. Click “Excel” in toolbar to download the current view.
  4. Select a row’s “Edit” link to update computer details.

TreeGrid Sample
Figure: Computers Index with Filter, Paging & Export


10. UML Class Diagram 🧩

@startuml
class ComputerListViewModel {
  +AssetStatus Status
  +IEnumerable<Computer> Computers
}

class Computer {
  +int Id
  +string MakeAndModel
  +string OperatingSystem
  +string SerialNumber
  +string AssetNumber
  +string CpsNumber
  +string EmployeeId
  +string OwnerFullName
  +DateTime PurchaseDate
  +DateTime EndOfWarranty
  +AssetStatus Status
  +bool NeedsReview
}

ComputerListViewModel "1" --> "*" Computer
@enduml

11. Conclusion ✅

This Index.cshtml view delivers a powerful and user‑friendly asset management interface, leveraging the Syncfusion TreeGrid for:

  • Advanced filtering, sorting & paging
  • Hierarchical data presentation
  • Rich export capabilities

By combining ASP.NET Core’s Razor syntax, strongly‑typed view models, and client‑side scripting, the page ensures a seamless IT administrative experience.

Next Steps:

  • Controller: Ensure Index action populates ViewBag.dataSource and ComputerListViewModel.
  • Security: Verify role‑based access for Create/Edit/Delete links.
  • Performance: Paginate large datasets server‑side if needed.

Happy coding! 🎉