IrbyImaging: WIPExtract.cshtml Documentation


Table of Contents

  1. Overview & Purpose 📋
  2. Dependencies & Technologies 🛠️
  3. Key Functional Areas 🚀
  4. View Models & Data Models 📊
  5. API Endpoints Overview 🌐
  6. Helper Methods & Utilities 🔧
  7. Error Handling & Return Types 🚨
  8. Third‑party Integrations 🔌
  9. Sample Code Blocks 💻
  10. Usage Examples 🎯
  11. UML Diagrams 📈
  12. Conclusion & Next Steps 🏁

Overview & Purpose 📋

File: IrbyImaging/Views/IView/WIPExtract.cshtml
This Razor view renders an interactive Work‑In‑Progress (WIP) Report using the Syncfusion EJ2 Grid.
It provides:

  • 🔍 Text Search
  • 📊 Sortable, Filterable, Groupable columns
  • ➕ Add, ✏️ Edit, 🗑️ Delete records via AJAX
  • 📥 Export to Excel / PDF
  • 🔗 Hierarchy (Parent/Child jobs) with infinite scrolling

This page is served by the IViewController at the route /IView/WIPExtract.


Dependencies & Technologies 🛠️

Category Details
Frontend Framework ASP.NET MVC Razor (.cshtml)
Grid Component Syncfusion Essential JS 2 (EJ2)
Layout Template ~/Views/Shared/_iViewLayout.cshtml
Namespaces @using Syncfusion.EJ2;@using Syncfusion.JavaScript;@using Syncfusion.JavaScript.Models;
Data Source ViewBag.WIP (server‐populated list of WIP items)
Data Manager Adaptor RemoteSaveAdaptor (for AJAX CRUD)

Key Functional Areas 🚀

  1. Toolbar & Search

    • A search input + Search button triggers grid.search().
    • Toolbar buttons: Add, Edit, Delete, Update, Cancel, ExcelExport, PdfExport.
  2. Grid Configuration

    • Infinite scrolling, frozen first 2 columns.
    • Excel‐style filters, multi‐sorting, grouping.
    • Column resizing, text wrap, reordering, column menu.
    • Auto‑fit column widths on data bind.
  3. AJAX CRUD

    • <e-data-manager> handles Create/Read/Update/Delete via:
      • /IView/Insert
      • /IView/Update
      • /IView/Delete
  4. Export

    • Excel and PDF export via grid.excelExport() and grid.pdfExport().
  5. Event Handlers

    • dataBound → Auto-fits columns
    • toolbarClick → Captures export toolbar actions
    • Inline script for Search button
    • onChange → (example) toggles grid lines

View Models & Data Models 📊

The grid columns map to a WIP C# model (populated in ViewBag.WIP).
Below is a representative table of properties:

Property Type Description
JobNumber string Unique job identifier
JobName string Name/title of the job
State string Current state or status
Division string Business division / department
TypeOfWork string Category of the work
FieldOffice string Assigned field office
Lead string Project lead or owner
Revenue, Cost decimal Financial metrics
Margin decimal Profit margin (Revenue − Cost)
RevenueYTD, … decimal Year‑to‑date metrics
ManHours decimal Total labor hours
CIEB, Unbilled, … decimal Additional financial fields
ParentJob bool Is this a parent job?
ChildJob bool Is this a child job?
ParentJobNumber string Link to the parent job’s ID

Example Controller Setup

public ActionResult WIPExtract()
{
    var wipList = _wipService.GetAllWIP(); // returns List<WIP> 
    ViewBag.WIP = wipList;
    return View();
}

API Endpoints Overview 🌐

CRUD operations are routed through:

Operation URL HTTP Method Payload
Insert /IView/Insert POST JSON serialized WIP
Update /IView/Update POST JSON serialized WIP
Delete /IView/Delete POST JSON { key: JobNumber }

Ensure your controller actions return JsonResult with success status + message.


Helper Methods & Utilities 🔧

JavaScript Handlers

// 1. Auto-fit all columns after data bind
function dataBound(args) {
  this.autoFitColumns([
    'JobNumber','JobName','State','Division','TypeOfWork','FieldOffice',
    'Lead','Revenue','Cost','Margin','RevenueYTD','CostYTD','MarginYTD',
    'ManHours','CIEB','Unbilled','BIEC','ParentJob','ChildJob','ParentJobNumber'
  ]);
}

// 2. Toolbar click => Export actions
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();
}

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

// 4. Example onChange to toggle grid lines
function onChange(e) {
  var treegrid = document.getElementById("TreeGrid").ej2_instances[0];
  treegrid.gridLines = e.value;
}

CSS Overrides

/* Remove extra padding from EJ2 checkboxes */
#property td div.e-checkbox-wrapper {
  padding-left: 0 !important;
  padding-top: 0 !important;
}

/* Minimum width for type drop-down (if used) */
#typeddl {
  min-width: 100px;
}

Error Handling & Return Types 🚨

  • Syncfusion Grid: Hook into its actionFailure or dataBound events to catch errors.
  • Controller:
    [HttpPost]
    public JsonResult Update(WIP model)
    {
        bool success = _wipService.Update(model);
        return Json(new {
          success,
          message = success ? "Updated successfully" : "Update failed"
        });
    }
    
  • Surface errors in the UI (e.g., alert() or a toast notification).

Third‑party Integrations 🔌

  • Syncfusion EJ2
    • Grid: <ejs-grid>
    • Data Manager: <e-data-manager>
    • Button: <ejs-button>
    • Excel & PDF Export modules
  • Mermaid (optional, for embedding UML in docs)

Sample Code Blocks 💻

Razor Markup Snippet

<ejs-grid id="TreeGrid" dataSource="ViewBag.WIP"
          allowFiltering="true" allowSorting="true"
          allowGrouping="true" toolbar="@(new List<string>{
            "Add","Edit","Delete","Update","Cancel","ExcelExport","PdfExport"
          })"
          toolbarClick="toolbarClick" dataBound="dataBound"
          allowExcelExport="true" allowPdfExport="true">
  <e-data-manager adaptor="RemoteSaveAdaptor"
                  insertUrl="/IView/Insert"
                  updateUrl="/IView/Update"
                  removeUrl="/IView/Delete">
  </e-data-manager>
  <e-grid-columns>
    <e-grid-column field="JobNumber" headerText="Job#" width="100"></e-grid-column>
    <!-- ...other columns... -->
  </e-grid-columns>
</ejs-grid>

Usage Examples 🎯

  1. Search
    • Enter “Acme” in the text field, click Search.
  2. Add
    • Click Add, fill row, click Update.
  3. Export
    • Click Excel Export or PDF Export in toolbar.
  4. Group
    • Drag Division column header to the grouping pane.

UML Diagrams 📈

Class Diagram (Mermaid)

classDiagram
    class WIP {
        +string JobNumber
        +string JobName
        +string State
        +string Division
        +decimal Revenue
        +decimal Cost
        +decimal Margin
        +bool ParentJob
        +bool ChildJob
        +string ParentJobNumber
    }
    class IViewController {
        +ActionResult WIPExtract()
        +JsonResult Insert(WIP)
        +JsonResult Update(WIP)
        +JsonResult Delete(int)
    }
    IViewController --> WIP : manages CRUD operations

Conclusion & Next Steps 🏁

This view delivers a robust, interactive WIP reporting tool, leveraging Syncfusion EJ2 for rich functionality.
Next Steps:

  1. Implement / Verify controller methods (Insert, Update, Delete).
  2. Enhance error‑feedback in the UI (notifications, toasts).
  3. Style to match your corporate theme.
  4. Write unit/integration tests for the API endpoints.

✨ Happy coding and may your WIP data always stay in sync! 🚀