๐Ÿ“„ PurchaseOrderDirectory.cshtml Documentation


๐Ÿ“‘ Table of Contents

  1. Overview & Purpose
  2. Key Functional Areas
    1. Syncfusion TreeGrid Configuration
    2. Search Functionality
    3. Toolbar & Export Features
    4. Job Link Template
    5. Column Formatting & Styling
  3. Dependencies & Technologies
  4. View Models & Data Models ๐Ÿ—‚๏ธ
  5. Helper Methods & Utilities โš™๏ธ
  6. Third-Party Integrations ๐Ÿค
  7. Sample Code Blocks & Usage Examples ๐Ÿ’ป
  8. UML Class Diagram ๐Ÿ› ๏ธ
  9. 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 IrbyImaging application under Views/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 by ViewBag.datasource (an IEnumerable<WorkOrder>).
  • childMapping: Nodes expand/collapse via the Children property on each WorkOrder.
  • 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()

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
  • WorkOrder has a 1โ€“* relationship to itself via Children
  • WorkOrder โ†’ Job for 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! ๐Ÿš€