🚀 Welcome to MDriven Learn –  Don’t miss the latest Release Notes.
Act as For Actions

In the ViewModel Editor, the property "Act As For Actions" helps you in the following ways:

  • If you have a grid with objects of type B, but many of the actions you want to expose on these objects reside in class A, enter an expression in the "Act As For Actions" that navigates from type B to type A (the expression must end up in 1 or 0 objects). This saves you the trouble of creating new class actions on B that repeat the logic for the class actions on A. This will make your Bs act as As when deciding what actions to expose.

This scenario is common for association objects (multi-link between A and C with a link to class B in between).

You want the precision B offers in the grid but with the actions of A also available. In this case, the context is B, and the expression would be self.A.

Example

Category class may have actions that you would like to access within the Sale class or ProductSale class ViewModels.

For this example, the ShowCategory class action on Category ViewModel can be accessed within the ProductSale actions using the Act As For Actions property.

Within the Product Sale Nested ViewModel, set Act As For Actions to point to the Category object from the ProductSale object.

With this, Category actions will be available and accessible from the ProductSale actions context.

Act As For Actions example