---
title: Generate the cascade script
summary: Builds the client-side BeforeEdit<Column2Key> function that replaces the child column's value list based on the parent cell value.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-08-17
library: SAIF.Presentation.Web.Controls.Infragistics111
reference_type: package
operation_id: OP-02
trigger: Called from DataBind (as part of Cascade grid drop-down value lists); also callable directly by consumers as a public method
---

# Generate the cascade script

This operation assembles the JavaScript function body that the grid invokes before a cell enters edit mode, so the child column's value list is rebuilt from only the options matching the parent column's current value.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-02 |
| **Trigger** | Called from [Cascade grid drop-down value lists](cascade-grid-dropdown-value-lists.md) (step 7); also callable directly by consumers as a public method |
| **Inputs** | `l1`, `l2`, `Column1.Key`, `Column2.Key` |
| **Outputs** | A `String` containing a complete `<script>` block defining `BeforeEdit<Column2Key>(gridName, cellId)` |
| **Primary components** | `clsDropDownController.GenerateJavaScript` |
| **Entry point** | `SAIF.Presentation.Web.Controls.Infragistics111/clsDropDownController.vb` |

## Steps

1. Open a `<script type="text/javascript">` block and emit the function header `function BeforeEdit<Column2.Key>(gridName, cellId){` ([BR-CTL-003](../business-rules.md#br-ctl-003-cascade-handler-name-derived-from-child-column-key)).
2. Emit lookups of the current column and row via the Infragistics client API (`igtbl_getColumnById`, `igtbl_getRowById`).
3. Emit an early-return guard: if the edited column's `Key` is not `Column2.Key`, the function returns without altering the value list ([BR-CTL-001](../business-rules.md#br-ctl-001-filter-child-drop-down-by-parent-value)).
   - If the edited column is not the child column: the guard short-circuits and the value list is left unchanged.
4. Emit retrieval of the parent cell value via `row.getCellFromKey("<Column1.Key>").getValue()` and declare an empty `vListFilter` array.
5. Emit a `switch(catCell)` statement with one `case "<item1.id>":` per entry in `l1` ([BR-CTL-001](../business-rules.md#br-ctl-001-filter-child-drop-down-by-parent-value)).
6. Within each case, emit one `vListFilter[n] = new Array("<item2.id>","<item2.desc>")` line for each `l2` entry whose `key.ToUpper` equals that parent `id.ToUpper` ([BR-CTL-002](../business-rules.md#br-ctl-002-case-insensitive-parent-child-key-match)).
   - If a parent value has no matching children: the emitted filter array is empty, which clears the child list at runtime.
   - On failure: an `l2` entry with a `Nothing` `key` raises a `NullReferenceException` on `.ToUpper` — no guard exists.*
7. Emit `col.ValueList=vListFilter;`, close the function and the `<script>` block, and return the string. Values are concatenated without JavaScript/HTML encoding ([BR-CTL-006](../business-rules.md#br-ctl-006-generated-script-values-are-not-encoded)).

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([GenerateJavaScript called]) --> S1["Emit function header<br>BeforeEdit + Column2.Key"]
	S1 --> S2["Emit column/row lookups"]
	S2 --> D{"Edited column ==<br>Column2.Key?"}
	D -->|No| EndNoop(["Return without change"])
	D -->|Yes| S3["Emit switch(catCell)<br>one case per l1 item"]
	S3 --> S4["Emit filtered vListFilter<br>from matching l2 items"]
	S4 --> S5["Emit col.ValueList = vListFilter"]
	S5 --> EndOk(["Return script string"])
```

## Failure and edge-case behavior
- An `l2` entry whose `key` is `Nothing` raises an unhandled `NullReferenceException` when `.ToUpper` is called during script generation — there is no null guard.*
- A parent value with no matching child entries produces an empty filter array, which clears the child column's value list at runtime rather than leaving it unchanged.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

> **Note:** Statements marked with `*` were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.

## Sources
- `SAIF.Presentation.Web.Controls.Infragistics111/clsDropDownController.vb`
