π Documentation: IrbyImaging/Views/Manufacturers/Index.cshtml
Table of Contents
- Overview & Purpose
- Key Functional Areas
- Dependencies & Technologies
- View Model & Data Model
- HTML & Razor Markup Breakdown
- Scripts & ThirdβParty Integrations
- Usage Examples
- UML Class Diagram
- Conclusion
Overview & Purpose
This Razor view renders a list of manufacturers within the IrbyImaging ASP.NET Core MVC application. It leverages the powerful DataTables jQuery plugin for rich table features (sorting, searching, exporting), and displays:
- A header with the total count of manufacturers
- A button to add a new manufacturer
- An interactive, exportable data grid
β¨ Intended Audience: Frontβend developers integrating DataTables with MVC, and backβend developers maintaining manufacturer administration.
Key Functional Areas
| Section | Description |
|---|---|
| ViewData / Layout | Sets the page title and applies the shared _ATSLayout.cshtml. |
| Header & Actions | Displays a <h2> with a dynamic badge of the total manufacturer count, and an βAdd New Manufacturerβ button. |
| Table Markup | Defines a <table> with column headers for Name, Availability, and Update action. |
| Data Binding | Loops through Model (IEnumerable<Manufacturer>) to render each row with Razor HTML Helpers (DisplayFor, Url.Action). |
| Scripts Section | Loads CSS/JS for DataTables, Buttons, jQuery, Bootstrap, and initializes the table with CSV/Excel/Print export buttons. |
Dependencies & Technologies
| Category | Libraries / Frameworks |
|---|---|
| ASP.NET Core MVC | Razor Views, HTML Helpers (DisplayNameFor, DisplayFor, Url.Action) |
| CSS Framework | Bootstrap 4, Custom Irby Styles (irby-blue, irby-green) |
| JavaScript Framework | jQuery 3.5.1 |
| DataTables Plugins | jquery.dataTables.min.css/js, dataTables.bootstrap4.min.css/js, Buttons (csv, etc.) |
| Export Utilities | JSZip, pdfmake, pdfmake vfs_fonts |
| UI Helpers | MetisMenu, Simplebar, Node-waves |
View Model & Data Model
// Located in IrbyImaging.DomainClasses
public class Manufacturer
{
public int Id { get; set; } // Primary key
public string Name { get; set; } // Display name
public bool IsAvailableOption { get; set; } // Availability flag
}
@model IEnumerable<Manufacturer>
The view expects a collection ofManufacturerobjects.
HTML & Razor Markup Breakdown
@model IEnumerable<IrbyImaging.DomainClasses.Manufacturer>
@{
ViewData["Title"] = "Manufacturer List";
Layout = "~/Views/Shared/_ATSLayout.cshtml";
}
<h2>
Manufacturers
<span class="badge irby-blue">@Model.Count()</span>
</h2>
<p>
<a asp-action="Create" class="btn-sm btn-success irby-green">
β Add New Manufacturer
</a>
</p>
-
Page Configuration
ViewData["Title"]sets the browser tab title.Layoutreferences a shared master layout.
-
Header
- Displays βManufacturersβ and a badge with
@Model.Count(). - Emoji usage (β) enhances UI clarity.
- Displays βManufacturersβ and a badge with
<table id="manufacturersDatatable" class="table table-striped table-bordered dt-responsive nowrap">
<thead>
<tr>
<th>@Html.DisplayNameFor(m => m.Name)</th>
<th>@Html.DisplayNameFor(m => m.IsAvailableOption)</th>
<th>Update</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>@Html.DisplayFor(m => item.Name)</td>
<td>@(item.IsAvailableOption ? "β
" : "β")</td>
<td>
<a href="@Url.Action("Edit", "Manufacturers", new { id = item.Id })"
class="btn-sm btn-warning">
βοΈ Update
</a>
</td>
</tr>
}
</tbody>
</table>
DisplayNameFor/DisplayFor
Ensures column headings and cell values come from model metadata.- Availability Column
Renders β or β based onIsAvailableOption. - Update Action
Links to/Manufacturers/Edit/{id}.
Scripts & ThirdβParty Integrations
@section Scripts {
<!-- jQuery & DataTables Core -->
<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>
<!-- DataTables Buttons & Export -->
<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://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.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>
<!-- Bootstrap & UI Helpers -->
<script src="~/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="~/libs/metismenu/metisMenu.min.js"></script>
<script src="~/libs/simplebar/simplebar.min.js"></script>
<script src="~/libs/node-waves/waves.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#manufacturersDatatable').DataTable({
dom: 'Bfrtip',
buttons: ['csv', 'excel', 'print']
});
});
</script>
}
- DataTables Initialization
dom: 'Bfrtip'places buttons, filter, and table elements.- Buttons: CSV, Excel, Print.
- UIs: MetisMenu, Simplebar, NodeβWaves provide consistent lookβandβfeel.
Usage Examples
- Controller Action
public IActionResult Index() { var manufacturers = _manufacturerService.GetAll(); return View(manufacturers); } - Navigating the View
- URL:
/Manufacturers/Index - Click βAdd New Manufacturerβ to navigate to
/Manufacturers/Create. - Click ββοΈ Updateβ on a row to go to
/Manufacturers/Edit/{id}.
- URL:
- Exporting Data
- Use the CSV, Excel, or Print buttons embedded at the top of the table.
UML Class Diagram
ββββββββββββββββββββββββββββββ
β Manufacturer (Domain) β
ββββββββββββββββββββββββββββββ€
β - int Id β
β - string Name β
β - bool IsAvailableOption β
ββββββββββββββββββββββββββββββ
β²
β IEnumerable<Manufacturer>
β
ββββββββββββββββββββββββββββββ
β Index.cshtml (View) β
ββββββββββββββββββββββββββββββ€
β + Table of Manufacturers β
β + DataTables Integration β
ββββββββββββββββββββββββββββββ
Conclusion
This Index.cshtml view offers a user-friendly, data-driven interface for administrators to manage manufacturers. By combining ASP.NET Core MVC Razor syntax with DataTables for rich functionality (sorting, filtering, exporting), it delivers:
- A scalable solution for large datasets
- Responsive design via Bootstrap 4
- Quick actions (Create, Edit) integrated seamlessly
π Next Steps:
- Implement backend paging/filtering for very large lists
- Add delete confirmations or bulk operations
- Enhance accessibility (ARIA attributes)
Happy coding! π