An action <a href="/Documentation:Column" title="Documentation:Column" data-bs-title="Documentation:Column">column</a> within a <a href="/Training:ViewModel" title="Training:ViewModel" data-bs-title="Training:ViewModel">ViewModel</a> is used for adding a button. There are two ways to set execution expressions in a <a href="/Documentation:Nestings" title="Documentation:Nestings" data-bs-title="Documentation:Nestings">nested</a> ViewModel button:
- Using <a href="/Documentation:Class_actions" title="Documentation:Class actions" data-bs-title="Documentation:Class_actions">Class actions</a>
- Using ViewModel actions
Using a Class Action[<a href="/index.php?title=Documentation:Adding_Buttons_in_Nested_ViewModels&veaction=edit§ion=1" class="mw-editsection-visualeditor" title="Edit section: Using a Class Action" data-bs-title="Documentation:Adding_Buttons_in_Nested_ViewModels">edit</a> | <a href="/index.php?title=Documentation:Adding_Buttons_in_Nested_ViewModels&action=edit§ion=1" title="Edit section: Using a Class Action" data-bs-title="Documentation:Adding_Buttons_in_Nested_ViewModels">edit source</a>]
Adding a class action requires a root on a ViewModel.
- Add an action column in your ViewModel.
- Go to ViewModel Actions and click on Class Action to create a new Class Action.
- Double-click on the created Class Action to open the Actions Editor menu where you can edit the Class action name and execute expression for action.
- Go to the ViewModel and click on the new action column to show its settings on their right where you can link the column to the Class action.
<a href="/File:Adding_Nested_ViewModel_Button_2.png" class="image" data-bs-title="File:Adding_Nested_ViewModel_Button_2.png" data-bs-filetimestamp="20240613050328"><img alt="Adding Nested ViewModel Button 2.png" src="/images/thumb/8/89/Adding_Nested_ViewModel_Button_2.png/922px-Adding_Nested_ViewModel_Button_2.png" decoding="async" width="922" height="534" srcset="/images/thumb/8/89/Adding_Nested_ViewModel_Button_2.png/1383px-Adding_Nested_ViewModel_Button_2.png 1.5x, /images/thumb/8/89/Adding_Nested_ViewModel_Button_2.png/1844px-Adding_Nested_ViewModel_Button_2.png 2x" /></a>
Using a ViewModel Action[<a href="/index.php?title=Documentation:Adding_Buttons_in_Nested_ViewModels&veaction=edit§ion=2" class="mw-editsection-visualeditor" title="Edit section: Using a ViewModel Action" data-bs-title="Documentation:Adding_Buttons_in_Nested_ViewModels">edit</a> | <a href="/index.php?title=Documentation:Adding_Buttons_in_Nested_ViewModels&action=edit§ion=2" title="Edit section: Using a ViewModel Action" data-bs-title="Documentation:Adding_Buttons_in_Nested_ViewModels">edit source</a>]
For this option to work, the action column name must be the same as the ViewModel action name.
- Add an action column in your ViewModel.
- Go to ViewModel actions and click on ViewModel action to create a new ViewModel action.
- Double-click on the created ViewModel action to open the Actions Editor menu where you can edit the ViewModel action name and execute expression for action.
- Set a name that will be the same as the name of the action column.
- Go back to the ViewModel and click on the new action column to show its settings on the right. Make sure the name for the column is the same as the one for the new ViewModel action.
NOTE: Do not link the created ViewModel action to the action column. The button/action column will work automatically and execute the ViewModel action expression.
<a href="/File:Adding_Nested_ViewModel_Button_1.png" class="image" data-bs-title="File:Adding_Nested_ViewModel_Button_1.png" data-bs-filetimestamp="20240611074345"><img alt="Adding Nested ViewModel Button 1.png" src="/images/thumb/d/d4/Adding_Nested_ViewModel_Button_1.png/910px-Adding_Nested_ViewModel_Button_1.png" decoding="async" width="910" height="444" srcset="/images/thumb/d/d4/Adding_Nested_ViewModel_Button_1.png/1365px-Adding_Nested_ViewModel_Button_1.png 1.5x, /images/thumb/d/d4/Adding_Nested_ViewModel_Button_1.png/1820px-Adding_Nested_ViewModel_Button_1.png 2x" /></a>