πŸ“ Documentation: balancesCostModal.cshtml


Table of Contents

  1. πŸ“– Overview & Purpose
  2. πŸ“‚ File Location
  3. 🧩 Dependencies & Technologies
  4. πŸ”‘ View Models & Data Models
  5. πŸ—‚οΈ UI Structure & Components
  6. 🎨 Styling
  7. πŸ“œ Scripts & Third‑Party Integrations
  8. πŸ”„ Sample Usage & Code Snippets
  9. πŸ“Š UML Diagram
  10. βœ… Conclusion

πŸ“– Overview & Purpose

balancesCostModal.cshtml is an ASP.NET MVC Razor partial view designed to present a tabular breakdown of cost details (jobs, cost codes, descriptions, and amounts). It is typically rendered inside a modal dialog within the IrbyImaging web application to allow users to export or print cost analyses for billing or review purposes.

  • Displays a DataTable with features like CSV/Excel export, print, pagination, and responsive layout.
  • Leverages jQuery DataTables and the Buttons extension for rich interactivity.
  • Commented out code hints at a previous attempt to use Syncfusion EJ2 Grid.

πŸ“‚ File Location

IrbyImaging/
 └── Views/
     └── IView/
         └── balancesCostModal.cshtml

🧩 Dependencies & Technologies

Dependency Version / Source Purpose
ASP.NET MVC Razor Built-in Server‑side templating
jQuery 3.5.1 (via CDN) DOM manipulation & DataTables support
DataTables 1.10.25 (CSS/JS via CDN) Table rendering & interactivity
DataTables Buttons Extension 1.7.1 Export (CSV/Excel) & print buttons
JSZip 3.1.3 Excel generation
pdfmake 0.1.53 PDF export
DataTables Bootstrap 4 Styles dataTables.bootstrap4.min.css Bootstrap 4 table styles

πŸ”‘ View Models & Data Models

Model Binding

@model IrbyImaging.UI.Models.Balances

Balances Model (Simplified)

Property Type Description
Details IEnumerable<BalanceDetail> Collection of individual cost rows
TotalCost decimal (Optional) Aggregate cost
...others Additional summary properties As needed by UI

BalanceDetail (Per‑Row Item)

Property Type Description
JobNumber string Identifier of the job
JobName string Friendly job title
CostCode string Accounting cost code
CostCodeDescription string Human‑readable description
Cost decimal Monetary cost value

πŸ—‚οΈ UI Structure & Components

<div class="row">
  <div id="ControlRegion">
    <!-- DataTable Definition -->
    <table id="jobDatatable" class="table table-striped table-bordered dt-responsive nowrap cell-border">
      <thead>
        <tr>
          <th>Job Number</th>
          <th>Job Name</th>
          <th>Cost Code</th>
          <th>Description</th>
          <th>Cost</th>
        </tr>
      </thead>
      <tbody>
        @foreach (var item in Model.Details) {
          <tr>
            <td>@Html.DisplayFor(m => item.JobNumber)</td>
            <td>@Html.DisplayFor(m => item.JobName)</td>
            <td>@Html.DisplayFor(m => item.CostCode)</td>
            <td>@Html.DisplayFor(m => item.CostCodeDescription)</td>
            <td>@Html.DisplayFor(m => item.Cost)</td>
          </tr>
        }
      </tbody>
    </table>
  </div>
</div>

Key Functional Areas

  1. Table Header
    Defines the columns: Job Number, Job Name, Cost Code, Description, Cost.

  2. Body Generation
    Iterates over Model.Details and binds each property to its cell.

  3. Commented Syncfusion Grid
    A block of <ejs-grid> markup (Syncfusion EJ2) is wrapped in Razor comments (@* ... *@), indicating an alternative implementation.


🎨 Styling

  • Bootstrap 4 table classes:

    • .table-striped, .table-bordered
  • DataTables Responsive:

    • .dt-responsive, .nowrap, .cell-border
  • Custom CSS snippet:

    <style>
      #jobDatatable {
        display: table-header-group; /* Ensures header remains visible */
      }
    </style>
    

πŸ“œ Scripts & Third-party Integrations

<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.7.1/js/dataTables.buttons.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.print.min.js"></script>

Initialization

<script>
  $(document).ready(function () {
    $('#jobDatatable').DataTable({
      dom: 'Bfrtip',
      buttons: ['csv', 'excel', 'print']
    });
  });
</script>
  • dom: 'Bfrtip'
    Layout for Buttons (B), filter input (f), table (t), pagination (p), etc.
  • Buttons Array
    Enables CSV, Excel, Print exports.

πŸ”„ Sample Usage & Code Snippets

Partial View Invocation

In a parent view or controller action, you can render the modal as follows:

@{ 
  var balancesModel = new Balances {
    Details = GetBalanceDetailsFromService()
  };
}
@Html.Partial("IView/balancesCostModal", balancesModel)

Or via AJAX:

$.get('/IView/GetBalances', { id: selectedId })
  .done(function(html) {
    $('#modalContainer').html(html).modal('show');
  });

πŸ“Š UML Diagram

sequenceDiagram
  participant C as Controller
  participant V as balancesCostModal.cshtml
  participant D as DataTables

  C->>V: Passes Balances model
  V->>V: Renders table rows for each BalanceDetail
  V->>D: Initializes DataTable with export buttons
  D->>User: Displays interactive grid

βœ… Conclusion

This balancesCostModal.cshtml partial view offers a responsive, exportable, and print-friendly display of cost data. By binding an IEnumerable<BalanceDetail> model to a jQuery DataTable, users can filter, sort, and export financial details seamlessly. The commented-out Syncfusion grid code serves as a reference for an alternate grid implementation.

Next Steps

  • Ensure the controller populates the Balances model correctly.
  • Style the modal container to fit your UI framework (Bootstrap, custom CSS).
  • Test export functions in all supported browsers.

Thank you for reviewing this detailed documentation! πŸš€