📝 Documentation: getAccountBalanceDetailType.cshtml
Location:
IrbyImaging/Views/IView/getAccountBalanceDetailType.cshtml
Purpose: Displays detailed account balance types for jobs, including nested grids, dynamic charts, Bing Maps integration, and AJAX‑powered modals.
📑 Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- Key Functional Areas
3.1 Razor Imports & Layout
3.2 Syncfusion TreeGrid & Child Grid
3.3 Chart Components
3.4 Bing Maps Integration
3.5 AJAX Modals & Templates
3.6 Styling & Themes
3.7 Client-side Utilities & Events - Data Models & ViewBag Sources
- API Endpoints & AJAX Calls
- Third‑Party Integrations
- Error Handling & Return Types
- UML Diagrams
- Sample Usage & Code Snippets
- Conclusion & Next Steps
1. Overview & Purpose 🎯
This Razor view provides a comprehensive dashboard for viewing account balance details by job type. It combines:
- A tree grid with expandable child grids for detailed line‑item balances
- Multiple Syncfusion EJ2 charts (line, column, pie)
- An interactive Bing Maps panel plotting job locations
- AJAX‑powered modals to drill into MTD/YTD revenue, cost, hours
It is intended for project managers and financial analysts to explore revenue/cost performance, unbilled amounts, margins, and job location data in a unified interface.
2. Dependencies & Technologies 🔧
| Technology / Library | Usage |
|---|---|
| ASP.NET MVC Razor | Server‑side view rendering |
| Syncfusion EJ2 (Grids, Charts) | High‑performance UI components (TreeGrid, Grid, Charts) |
| Microsoft Bing Maps API | Plotting job locations with pushpins, routing, autosuggest |
| jQuery | Event delegation, AJAX calls |
| Bootstrap (CSS & JS) | Responsive layout, modals, cards |
| DataTables (JS includes) | Future enhancements / table exports |
3. Key Functional Areas
3.1 Razor Imports & Layout 🏗️
@using Syncfusion.EJ2
@using Syncfusion.EJ2.Grids
@using Syncfusion.EJ2.Maps
@{ Layout = "~/Views/Shared/_iViewLayout.cshtml"; }
- Imports bring Syncfusion namespaces into scope.
- Layout ensures consistent header/footer and shared scripts.
3.2 Syncfusion TreeGrid & Child Grid 🌳
- Parent
ejs-gridwithdataSource=ViewBag.datasource, stacked columns for Current Month and YTD by Lead. - Child Grid defined in C# razor:
var childGrid = new Grid() { DataSource = ViewBag.datasource8, QueryString = "Type", Columns = new List<GridColumn> { /* JobNumber, JobName, Revenue, Cost, … */ } }; - Features
- Infinite scrolling
- Excel/PDF export
- Auto‑fit columns on dataBound
| Feature | Description |
|---|---|
childGrid |
Nested rows per lead type |
allowExcelExport / allowPdfExport |
Export current view |
dataBound |
Auto‑fit column widths |
3.3 Chart Components 📈
- Revenue & Cost (Trailing 12 Months)
- Type:
StackingLine
- Type:
- Unbilled (Trailing 12 Months)
- Type:
Column
- Type:
- Total Margin by Job
- Type:
AccumulationChart(Pie/Doughnut)
- Type:
- CIEB vs. BIEC (Month)
- Type:
StackingColumn
- Type:
<ejs-chart title="Revenue and Cost by Month - Trailing 12 Months">
<e-series-collection>
<e-series type="StackingLine" name="Revenue" ... />
<e-series type="StackingLine" name="Cost" ... />
</e-series-collection>
</ejs-chart>
3.4 Bing Maps Integration 🗺️
- Dynamic load of Bing Maps script with your
bingKey. GetMap()initializes map, infobox, directions manager, traffic layer, autosuggest.- Plotting Job Locations
fetch('/IView/GetJobLocations', { method:'POST', body: new URLSearchParams({ key: '@ViewBag.returnItem' }) }) .then(r => r.json()).then(locations => { /* pushpins, fit to bounds */ }); - Utilities:
showInfobox(pin, locationData)startTracking()/stopTracking()switchToBirdseye()suggestionSelected(result)
3.5 AJAX Modals & Templates 🔄
- Usage of
<script type="text/x-template" id="typetemplate2">to define clickable cells. - jQuery delegates click events:
$('body').on('click', '#revenueMTD', function(){ $.get('/IView/balancesModal', { id, Year }, html => { $('#myModalContent').html(html); $('#myModal').modal('show'); }); }); - Endpoints:
/IView/balancesModal/IView/balancesCostModal/IView/balancesHoursModal/IView/balancesModalYTD/IView/balancesCostModalYTD
3.6 Styling & Themes 🎨
- Custom CSS classes for Syncfusion headers:
.e-custom1….e-custom11
- Grid row height fixed at
12pxfor compactness. - Modal & Button styles using Bootstrap and utility classes.
3.7 Client-side Utilities & Events ⚙️
| Function | Description |
|---|---|
dataBound, dataBound11 |
Auto‑fit columns on data load |
load10() |
Column formats (date, currency) |
toolbarClick() |
Syncfusion export toolbar handlers |
highlight() |
Temporarily highlight events on map |
4. Data Models & ViewBag Sources
ViewBag.datasource&datasource8: collections ofType,Revenue,Cost,Margin, etc.- Chart Sources:
ViewBag.chartSourceViewBag.chartSourceunbilledViewBag.chartSourcemarginViewBag.chartSourcecieb/chartSourcebiec
- Job Details:
ViewBag.Jobsfor the second TreeGrid (JobLocations & JobDetails)
Data Shapes include fields like:
JobNumber,JobName,YTDRevenue,ManHours- Chart points:
{ x: "Jan", y: 120000 }
5. API Endpoints & AJAX Calls 📡
| Endpoint | Method | Input | Return |
|---|---|---|---|
/IView/GetJobLocations |
POST | key: string |
[{ Latitude, Longitude, Job,… }] |
/IView/balancesModal |
GET | id, Year |
PartialView HTML |
/IView/balancesCostModal |
GET | id, Year |
PartialView HTML |
/IView/balancesHoursModal |
GET | id, Year |
PartialView HTML |
/IView/balancesModalYTD |
GET | id, Year |
PartialView HTML |
/IView/balancesCostModalYTD |
GET | id, Year |
PartialView HTML |
6. Third‑Party Integrations 🌐
- Syncfusion EJ2 for all grids & charts
- Bing Maps JavaScript API for mapping & routing
- DataTables scripts are included (for future table export enhancements)
7. Error Handling & Return Types 🚨
- AJAX
.error()handlers trigger a simplealert("Dynamic content load failed."). - Infobox on map shows only when data present; else suppressed.
- Exports (Excel/PDF) guard against missing fonts in RTL scenarios.
8. UML Diagrams 📊
8.1 Component Diagram
graph LR
Controller[IViewController]
View[getAccountBalanceDetailType.cshtml]
GridComp[Syncfusion TreeGrid & Grid]
ChartComp[Syncfusion Charts]
MapComp[Bing Maps Integration]
ModalComp[AJAX‑powered Modals]
Controller --> View
View --> GridComp
View --> ChartComp
View --> MapComp
View --> ModalComp
Controller -->|GetJobLocations| MapComp
Controller -->|balancesModal etc.| ModalComp
8.2 Sequence: Revenue MTD Drill‑down
sequenceDiagram
participant User
participant Browser
participant Controller
User->>Browser: Click `$Revenue (MTD)` link
Browser->>Controller: GET /IView/balancesModal?id,Year
Controller-->>Browser: PartialView HTML
Browser->>Modal: Show modal with content
9. Sample Usage & Code Snippets 💡
9.1 Defining the Child Grid
@{
var childGrid = new Syncfusion.EJ2.Grids.Grid() {
DataSource = ViewBag.datasource8,
FrozenColumns = 2,
Columns = new List<GridColumn> {
new GridColumn { Field="JobNumber", HeaderText="Job#", Template="#typetemplate" },
new GridColumn { Field="Revenue", HeaderText="REVENUE", Format="C2" },
// …
}
};
}
9.2 AJAX Modal Trigger
$('body').on('click', '#revenueMTD', function() {
let id = $(this).data('id'),
year = $(this).data('Year');
$.get('/IView/balancesModal', { id, Year: year })
.done(html => {
$('#myModalContent').html(html);
$('#myModal').modal('show');
})
.fail(() => alert("Load failed."));
});
10. Conclusion & Next Steps ✅
This view orchestrates a rich, data‑driven UI combining grids, charts, and maps to deliver actionable insights into job‑based account balances.
Next Steps:
- Add role‑based filters (e.g., show only jobs assigned to the current user)
- Enhance error reporting with in‑page notifications
- Integrate real‑time updates via SignalR for streaming balance changes
Happy Visualizing & Analyzing! 🎉