π PncLookup.cshtml Documentation
π Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- View Model & Data Models
- Layout & ViewData
- UI Components & Search Form
5.1 Employee Dropdown
5.2 Date Pickers
5.3 Text Inputs
5.4 Action Buttons - Result Grid π
- JavaScript Functions & Logic
7.1 performSearch()
7.2 clearForm()
7.3 toolbarClick()
7.4 getComponentValue()
7.5 Filter Functions - AJAX Endpoint Overview
- Third-Party Integrations π
- Styling & CSS π¨
- Usage Examples & Code Snippets π‘
- UML Diagram π
- Conclusion π
1. Overview & Purpose π―
PncLookup.cshtml is an ASP.NET Razor view that enables users in the accounting imaging module to:
- π Search PNC (Purchasing Card) statements based on multiple criteria.
- π View results in an interactive grid with paging, sorting, filtering, and export capabilities.
- π₯ Export the search results to Excel with custom formatting.
This page is part of IrbyImaging's AccountingImaging module and uses Syncfusion EJ2 controls for rich UI functionality.
2. Dependencies & Technologies π οΈ
| Category | Technology / Library |
|---|---|
| UI Framework | ASP.NET Core MVC (Razor views) |
| JS Component Library | Syncfusion EJ2 (ejs-grid, ejs-datepicker, ejs-dropdownlist, etc.) |
| Data Binding | ViewBag, Model (PncData) |
| AJAX & JSON | Fetch API, Newtonsoft.Json |
| AntiβForgery | @Html.AntiForgeryToken() |
| Styling | Bootstrap 4 / Custom CSS |
| Utilities | Syncfusion.JavaScript.Models |
| Date Handling | System.Globalization |
3. View Model & Data Models π·οΈ
@model IrbyImaging.UI.Models.PncData
PncData(C# Model)- Contains properties used for rendering and filtering PNC statements.
- Typical fields:
PostingDate,TransactionId,DepartmentOrJobNumber,Subsidiary, etc.
@using Newtonsoft.Json
@using System.Linq
- ViewBag
ViewBag.Employees&ViewBag.Jobs: Collections used as data sources for dropdown filters.
4. Layout & ViewData πΌοΈ
@{
ViewData["Title"] = "Search Statements";
Layout = "~/Views/Shared/_AccountingLayout.cshtml";
}
ViewData["Title"]sets the page title.Layoutreferences a shared layout to provide consistent header, footer, and navigation.
5. UI Components & Search Form π
The search form is organized into rows (.uniform-row) with multiple input controls:
5.1 Employee Dropdown
<ejs-dropdownlist id="employeeSearch"
dataSource="@ViewBag.Employees"
showClearButton="true"
allowFiltering="true"
filtering="employeeFilter"
placeholder="Select an Employee"
popupHeight="300px"
popupWidth="400px">
<e-dropdownlist-fields text="Text" value="Value"></e-dropdownlist-fields>
</ejs-dropdownlist>
- Features:
- Live filtering (
allowFiltering) - Clear button
- Custom popup size
- Live filtering (
5.2 Date Pickers
<ejs-datepicker id="DatePick"
placeholder="Select Date"
format="MM/dd/yyyy">
</ejs-datepicker>
<ejs-datepicker id="monthYear"
format="MMMM y"
placeholder="Select Month/Year"
start="Year"
depth="Year">
</ejs-datepicker>
DatePick: Single date selection.monthYear: Month-year only (no day granularity).
5.3 Text Inputs
<ejs-textbox id="merchant" placeholder="Enter Merchant"></ejs-textbox>
<ejs-textbox id="CCNumber" placeholder="XXXX"></ejs-textbox>
<ejs-textbox id="subsidiary" placeholder="Enter Subsidiary"></ejs-textbox>
<ejs-textbox id="workOrder" placeholder="Enter Work Order #"></ejs-textbox>
<ejs-textbox id="unitNumber" placeholder="Enter Unit #"></ejs-textbox>
- For free-text filters (merchant name, card last 4 digits, etc.).
5.4 Action Buttons
<ejs-button id="searchBtn" content="Search" isPrimary="true" cssClass="e-flat"></ejs-button>
<ejs-button id="clearBtn" content="Clear" cssClass="e-flat"></ejs-button>
<ejs-button id="exportBtn" content="Export to Excel" cssClass="e-flat"></ejs-button>
- Search: Triggers AJAX search.
- Clear: Resets form & hides grid.
- Export: Exports grid data to Excel.
6. Result Grid π
<ejs-grid id="ResultGrid"
allowPaging="true"
allowSorting="true"
allowFiltering="true"
allowResizing="true"
allowExcelExport="true"
toolbar="@(new List<string>() { "ExcelExport" })"
toolbarClick="toolbarClick"
gridLines="Both"
height="450">
<!-- Column definitions -->
<e-grid-columns>
<e-grid-column field="PostingDate" headerText="Posting Date" type="date" format="yMd" width="130"></e-grid-column>
<!-- More columns... -->
</e-grid-columns>
</ejs-grid>
- Key Features:
- Paging (15 rows/page)
- Excel-style filtering
- Export to Excel (via toolbar or separate button)
- Custom column formats (dates, currency)
7. JavaScript Functions & Logic π§©
All scripts run on DOMContentLoaded:
7.1 performSearch()
function performSearch() {
const formData = {
EmployeeJdeAB: getComponentValue('employeeSearch'),
TransactionDate: getComponentValue('DatePick'),
// ...
};
grid.showSpinner();
fetch('/AccountingImaging/SearchPnc', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'RequestVerificationToken': token
},
body: JSON.stringify(formData)
})
.then(res => res.json())
.then(data => {
grid.dataSource = data;
grid.refresh();
document.getElementById('resultContainer').style.display = '';
grid.hideSpinner();
})
.catch(err => {
console.error(err);
grid.hideSpinner();
alert('An error occurred while searching.');
});
}
- Flow:
- Gather form values
- Show loading spinner
- AJAX POST to
/AccountingImaging/SearchPnc - Populate grid & show results
- Error handling with alert
7.2 clearForm()
function clearForm() {
['employeeSearch','DatePick','monthYear','merchant','CCNumber','subsidiary','jobNameSearch','workOrder','unitNumber']
.forEach(id => {
const cmp = document.getElementById(id)?.ej2_instances?.[0];
if (cmp) cmp.value = cmp.value ? null : '';
});
document.getElementById('resultContainer').style.display = 'none';
grid.dataSource = [];
}
- Resets all controls and hides the grid.
7.3 toolbarClick()
Handles grid toolbar Excel export:
function toolbarClick(args) {
if (args.item.id === 'ResultGrid_excelexport') {
// Build excelExportProperties with custom widths & date formatting
grid.excelExport(excelExportProperties);
}
}
7.4 getComponentValue()
Generic helper to retrieve EJ2 component values:
function getComponentValue(id) {
const cmp = document.getElementById(id)?.ej2_instances?.[0];
return cmp ? cmp.value : null;
}
7.5 Filter Functions
function jobFilter(e) {
var query = new ej.data.Query();
if (e.text !== '') query = query.where('Text','contains',e.text,true);
e.updateData(@Html.Raw(JsonConvert.SerializeObject(ViewBag.Jobs)), query);
}
- Used by dropdowns for live filtering of large lists.
8. AJAX Endpoint Overview π‘
| Endpoint | HTTP Method | Payload | Description |
|---|---|---|---|
/AccountingImaging/SearchPnc |
POST | JSON formData (see above) | Returns filtered PncData[] |
- AntiβForgery Token is included in headers (
RequestVerificationToken).
9. Third-Party Integrations π
- Syncfusion EJ2
- Grid, DropdownList, DatePicker, TextBox, Button controls
- Excel export with custom styling
- Newtonsoft.Json for serializing
ViewBagdata into filter functions
10. Styling & CSS π¨
Custom styles ensure a clean and uniform look:
.uniform-row { margin-bottom: 15px; }
.form-group label { font-weight: 500; color: #495057; }
/* Grid theming */
.e-gridheader { background-color: #f8f9fa; }
.e-grid .e-rowcell { border-color: #e9e9ef; }
/* Responsive */
@media (max-width: 768px) {
.button-group { margin-top: 15px; }
}
- Responsive adjustments for mobile.
11. Usage Examples & Code Snippets π‘
Performing a Search
// User clicks "Search" β performSearch() runs
performSearch();
// Results appear in the grid.
Clearing the Form
// User clicks "Clear"
clearForm();
// All inputs reset, grid hidden.
Export to Excel
// Click "Export to Excel" button
exportBtn.element.addEventListener('click', () => {
grid.excelExport({ autoFit: true, fileName: 'PNC_Search_Results.xlsx' });
});
12. UML Diagram π
@startuml
title PncLookup.cshtml - Component Interaction
actor User
participant "PncLookup View" as View
participant "Syncfusion Grid" as Grid
participant "Controller" as Ctrl
participant "PncData Model" as Model
User -> View : Fill form & click Search
View -> Ctrl : POST /AccountingImaging/SearchPnc (formData)
Ctrl -> Model : Query DB & return List<PncData>
Model --> Ctrl : JSON data
Ctrl --> View : JSON response
View -> Grid : grid.dataSource = data
User -> Grid : Sort, Filter, Export
@enduml
13. Conclusion π
The PncLookup.cshtml page provides a rich, interactive interface for searching and exporting purchasing card transactions within the AccountingImaging module. Leveraging Syncfusion EJ2 controls and AJAX patterns, it delivers:
- Robust filtering across multiple dimensions
- Seamless Excel export with custom formatting
- Responsive, user-friendly UI
This documentation should empower developers to extend, maintain, and integrate the PNC lookup functionality confidently.