๐ PurchaseOrderDirectory.cshtml Documentation
๐ Table of Contents
- Overview & Purpose
- Key Functional Areas
- Dependencies & Technologies
- View Models & Data Models ๐๏ธ
- Helper Methods & Utilities โ๏ธ
- Third-Party Integrations ๐ค
- Sample Code Blocks & Usage Examples ๐ป
- UML Class Diagram ๐ ๏ธ
- Conclusion ๐ฏ
1. Overview & Purpose
This Razor view (PurchaseOrderDirectory.cshtml) renders a Purchase Order List as an interactive, featureโrich tree grid using Syncfusion EJ2 Grid in an ASP.NET Core MVC application.
- Intended Use: Display a hierarchical (parentโchild) list of purchase orders (WorkOrders), support searching, filtering, sorting, paging, exporting (Excel/PDF), and linking to related Job details.
- Context: Part of the
IrbyImagingapplication underViews/JDE, dealing with JDE (JD Edwards) purchase order integration/UI.
2. Key Functional Areas
2.1 Syncfusion TreeGrid Configuration
The core component is <ejs-grid> (Syncfusion EJ2 TreeGrid).
<ejs-grid id="TreeGrid"
load="load"
dataSource="ViewBag.datasource"
childMapping="Children"
showColumnMenu="true"
treeColumnIndex="0"
allowReordering="true"
allowFiltering="true"
allowSorting="true"
allowPaging="true"
allowMultiSorting="true"
allowResizing="true"
autoFit="true"
frozenColumns="3"
allowExcelExport="true"
allowPdfExport="true"
toolbar="@(new List<string>() { "ExcelExport", "PdfExport"})"
toolbarClick="toolbarClick">
<!-- page, filter, and column definitions omitted for brevity -->
</ejs-grid>
dataSource: Provided byViewBag.datasource(anIEnumerable<WorkOrder>).childMapping: Nodes expand/collapse via theChildrenproperty on eachWorkOrder.- Features Enabled: Filtering, sorting, multiโsorting, paging, text wrap, column reordering, Excel/PDF export, frozen columns, autoโfit.
Column Definitions
| Field | Header Text | Width | Filtering | Sorting |
|---|---|---|---|---|
| Name | Name | 150px | โ | โ |
| OrderNumber | Order# | 220px | โ | โ |
| Type | Type | 160px | โ | โ |
| Job.JdeNumber | Job# | 220px | โ | โ |
| Job.Name | JobName | 220px | โ | โ |
| OrderDate | Status | 200px | โ | โ |
| VendorNumber | Vendor# | 170px | โ | โ |
| VendorName | Vendor Name | 200px | โ | โ |
2.2 Search Functionality
A simple text search and button trigger the Gridโs built-in search:
<input type="text" id="searchText" placeholder="Search..." />
<ejs-button id="Search" content="Search" cssClass="e-primary"></ejs-button>
document.getElementById('Search').addEventListener('click', function() {
var val = document.getElementById('searchText').value;
var grid = document.getElementById('TreeGrid').ej2_instances[0];
grid.search(val);
});
- Search: Calls
grid.search(val)to filter rows across all columns.
2.3 Toolbar & Export Features
Syncfusion toolbar items trigger export:
function toolbarClick(args) {
var gridObj = document.getElementById("TreeGrid").ej2_instances[0];
if (args.item.id === 'TreeGrid_pdfexport') gridObj.pdfExport();
if (args.item.id === 'TreeGrid_excelexport') gridObj.excelExport();
}
- PDF Export:
pdfExport() - Excel Export:
excelExport()
2.4 Job Link Template
A custom column template displays clickable Job links:
<script id="jobtemplate" type="text/x-template">
<div class="image" id="edit">
<a target="_blank" href="/Jobs/Details/${JobId}">${Job.Name}</a>
</div>
</script>
${Job.Name}: Displays the Job name./Jobs/Details/${JobId}: Opens job details in a new tab.
2.5 Column Formatting & Styling
- Auto Fit Columns on Data Bound:
function dataBound(args) { this.autoFitColumns([ 'Name','OrderNumber','Type','Job.JdeNumber', 'Job.Name','OrderDate','VendorNumber','VendorName' ]); } - Date Format on Load:
function load(args) { this.columns[5].format = { type: 'date', format: 'MM/dd/yyyy' }; } - Custom CSS: Removes extra padding from checkboxes:
#property td div.e-checkbox-wrapper { padding-left: 0 !important; padding-top: 0 !important; }
3. Dependencies & Technologies
| Category | Technology / Library | Purpose |
|---|---|---|
| UI Framework | Bootstrap (v4/5) | Layout, grid, responsive styling |
| JS Grid | Syncfusion EJ2 (TreeGrid) | Data grid with advanced features |
| DOM Utilities | jQuery (v3.5.1) | DOM manipulation, ready events |
| Forms & Input | Select2 | Enhanced <select> inputs |
| Date Picker | bootstrap-datepicker | Date selection (if used elsewhere) |
| Rich Text | TinyMCE | WYSIWYG editor (if used elsewhere) |
| Utilities | simplebar, waves, spin.js | Custom scrollbars, ripple effects, spinners |
| Repeater | jquery.repeater | Dynamic form fields |
4. View Models & Data Models ๐๏ธ
Primary ViewModel: IrbyImaging.UI.Models.WorkOrders
public class WorkOrder {
public string Name { get; set; }
public string OrderNumber { get; set; }
public string Type { get; set; }
public DateTime OrderDate { get; set; }
public string VendorNumber { get; set; }
public string VendorName { get; set; }
public Job Job { get; set; }
public List<WorkOrder> Children { get; set; }
}
public class Job {
public int JobId { get; set; }
public string JdeNumber { get; set; }
public string Name { get; set; }
}
Children: Enables hierarchical display in TreeGrid.Job: Nested object for job details.
5. Helper Methods & Utilities โ๏ธ
| Function | Location | Description |
|---|---|---|
dataBound |
Inline script | Autoโfits all grid columns after data bind. |
load |
Inline script | Sets OrderDate column date format. |
toolbarClick |
Inline script | Handles Excel/PDF export clicks. |
onChange |
Inline script | Toggles collapsedStatePersist (unused flag). |
6. Third-Party Integrations ๐ค
- Syncfusion EJ2: Commercial UI controls โ TreeGrid, Buttons, Export modules.
- Select2: Enhances dropdowns; initialized on document ready:
$(document).ready(function () { $('.js-example-basic-single').select2(); }); - TinyMCE / Repeater: Loaded for other parts of the page/app (optional here).
7. Sample Code Blocks & Usage Examples ๐ป
Controller Action Example
public class JDEController : Controller
{
private readonly IOrderService _orderService;
public JDEController(IOrderService orderService) {
_orderService = orderService;
}
public IActionResult PurchaseOrderDirectory() {
var orders = _orderService.GetHierarchicalWorkOrders();
ViewBag.datasource = orders;
return View();
}
}
Invoking Search Programmatically
// Programmatically search for โABC123โ
var grid = document.getElementById('TreeGrid').ej2_instances[0];
grid.search('ABC123');
8. UML Class Diagram ๐ ๏ธ
classDiagram
class WorkOrder {
+string Name
+string OrderNumber
+string Type
+DateTime OrderDate
+string VendorNumber
+string VendorName
+List~WorkOrder~ Children
}
class Job {
+int JobId
+string JdeNumber
+string Name
}
WorkOrder --> Job
WorkOrder --> WorkOrder : Children
WorkOrderhas a 1โ* relationship to itself viaChildrenWorkOrderโJobfor nested job information
9. Conclusion ๐ฏ
This Purchase Order Directory view gives endโusers a powerful, responsive interface to:
- Browse hierarchical purchase orders
- Filter, sort, and page through large datasets
- Export listings to Excel/PDF
- Quickly navigate to related Job records
By leveraging Syncfusion EJ2 controls and common JS utilities (jQuery, Select2), this page balances rich functionality with maintainable Razor markup and inline scripts. It can serve as a template for other hierarchical data presentations in the IrbyImaging suite.
Happy coding! ๐