Skip to content

Architecture

This page describes how the drilldown plugs into the box module lifecycle and which existing infrastructure it relies on.

Lifecycle hooks

Three module lifecycle hooks are wired up on COrdersCausingShortages.

CreateInstance

A ShareID is set on the details query view so saved drilldown layouts are filtered to this module:

m_DetailsQueryView.Settings.ShareID = ModuleInfo.ModuleID & "_DetailsDrilldown"

This ensures that layouts a user saves while drilling into MRP Orders Causing Shortages are listed separately from layouts saved against the same underlying optimized table (MRP_Details) from other contexts.

Refresh

The main report's gridview is configured to highlight rows on hover, which is also what the framework uses to show the drilldown affordance:

Protected Overrides Sub Refresh()
    MainGridView.MouseOverStyle = MyGridView.MouseOverStyles.Row
End Sub

Why this matters

Without MouseOverStyle = Row, the drilldown cursor and row underline do not appear on the main report's rows.

Layout persistence: DataSaveBegin and DataLoadEnd

The drilldown's saved layout (visible columns, grouping, sort order, column widths, filter strings) is round-tripped through `MyData.m_DetailsLayout` so it persists across sessions:
Private Sub DataSaveBegin(ByVal sender As Object) Handles Settings.DataSave
    MyData.m_DetailsLayout = m_DetailsQueryView.MyData
End Sub

Private Sub DataLoadEnd(ByVal sender As Object) Handles Settings.DataLoad
    m_DetailsQueryView.MyData = MyData.m_DetailsLayout
End Sub
This is the supported way to persist a drilldown layout in the box module framework.

The OnDrillDown override

`OnDrillDown` is invoked by `CBoxModule` when the user double-clicks a data row on the main grid. The override:
1. Validates that the necessary columns are visible on the source report (`item_no`, `mrp_trx_dt`).
2. Reads `item_no`, `mrp_trx_dt`, and optionally `item_loc` from the clicked row.
3. Resolves the week range that contains `mrp_trx_dt` using the main calendar's `ProductionWeekStart`.
4. Queries `#FlatBOM` to find all item numbers related to the drilled item.
5. Sets mandatory matrix elements on `m_DetailsQueryView`.
6. Builds criteria on `PrimaryLayoutInterface.Criteria` for the resolved item list, optional location, and week range.
7. Applies a default layout if none is saved (see the [Default layout fallback](../default-layout/) page).
8. Opens the drilldown form via `PrimaryLayoutInterface.Layout.GetDrillDownForm` and `DisplayDrillDown`.
9. Attaches the cell color-coding handler and turns on `AutoExpandAllGroups`.

The control flow is sequential and entirely within `OnDrillDown` — there are no event subscriptions or asynchronous steps.

Reused infrastructure

The drilldown uses these existing components without modification:
- `PulseDevTools.DynamicQuery.CQueryView` and `CLayoutInterface` for the layout and criteria model.
- `Pulse.TableManager.Table(enumOptimizedTable.MRP_Details)` as the data source for the drilldown.
- `Pulse.Calendar.GetWeek(date, ProductionWeekStart)` for resolving the week containing a transaction date.
- `FDrilldown` as the drilldown form, accessed via `PrimaryLayoutInterface.Layout.GetDrillDownForm`.
- `AppCon.FillDataTable` for the one-shot BOM-related-item lookup query.

What was deliberately not added

- **No new tables or persistent state.** The drilldown reads from `#FlatBOM` (assumed present and in scope when the drilldown runs) and the standard MRP optimized table.
- **No changes to `RefreshMyOptimizedTable`.** The main report's view definition is unchanged.
- **No new matrix elements.** All columns the drilldown displays already existed in the matrix.