You can use #Nesting.MultiSelect on a nesting when users need to select multiple rows in its table or grid and use that selection in OCL.
What #Nesting.MultiSelect does
#Nesting.MultiSelect changes a nesting's table or grid from single-row selection to multi-row selection. When this setting is enabled, MDriven maintains a vSelected_ variable for that nesting.
The vSelected_ variable is a strongly typed collection containing the objects that the user has selected. Its postfix is the name of the nesting.
For example, if a ViewModel has a nesting named Order, the selected orders are available through:
vSelected_OrderUse this collection in OCL actions that should operate on all selected objects rather than only the row that currently has focus.
Enable multi-selection
- In MDriven Designer, locate the blue nesting in the top-level ViewModel that supplies the table or grid.
- Apply
#Nesting.MultiSelectto that nesting. - Use the nesting's
vSelected_collection in the OCL for actions that need the selected rows. - Run the ViewModel and select more than one row in the grid.
For example, an action can test whether the user has selected any orders before it continues:
vSelected_Order->size > 0The exact variable name depends on the nesting name. A nesting named Customer has vSelected_Customer; a nesting named Order has vSelected_Order.
vCurrent_ and vSelected_
Do not treat the current row and the selected rows as the same thing:
| Variable | Meaning | Example use |
|---|---|---|
vCurrent_
|
The object the user most recently focused or clicked. | Edit or inspect the current order. |
vSelected_
|
The collection of objects selected when multi-selection is enabled. | Perform an action for every selected order. |
MDriven creates and maintains both variables for each ViewModel nesting. Read VCurrent and vSelected before relying on either variable in an action, especially when the action mixes current-row behavior with multi-selection.
First-row selection
WebUI DataGrids automatically select the first row when the list does not use multi-selection. When #Nesting.MultiSelect is enabled, the default is instead not to select the first row automatically.
Set Nesting.AutoSelectFirstRow explicitly to true or false when your ViewModel requires a specific initial-selection behavior. This avoids making an action depend on an assumed current or selected row.
Client considerations
In Turnkey, a row can be included in vSelected_ through the selection control, while vCurrent_ tracks focus. These are maintained as separate concepts. In WPF, focused and selected behavior is naturally differentiated by the UI controls.
Multi-selection is row selection. If you need to select an individual cell or a rectangular group of cells in a native Windows client, use Nesting.CellSelect instead; it is not available in the web client.
