Ways to Hide or Disable an Action (Button, Menu Command)
- 3 minutes to read
You can hide or disable an Action. If an Action (button) is disabled, it is grayed out. The table below shows different Action states.
Description | Image |
---|---|
The Clear tasks Action is active. | |
The Clear tasks Action is disabled. | |
The Clear tasks Action is hidden. |
XAF allows you to change the state of custom and built-in Actions. The following topic describes how to identify built-in Actions: Determine an Action’s Controller and Identifier.
Ways to Disable an Action
You can utilize the following techniques to disable an Action (button, menu item):
Use the Enabled property. See the following topic for examples: Deactivate (Hide) an Action in Code.
Specify the ActionBase.TargetObjectsCriteria and ActionBase.SelectionDependencyType properties. When conditions specified in these properties are not met, an Action is disabled. Refer to the property descriptions for additional information.
Use the Conditional Appearance module. You can enable and disable Actions based on the specified rules (for example, disable an Action based on business object properties). Refer to the following topic for more information: Declare Conditional Appearance Rules in Code. See the rule with the ActionState ID in the Examples section.
Ways to Hide an Action
You can utilize the following techniques to hide an Action (button, menu item):
Use the Active property. See the following topic for examples: Deactivate (Hide) an Action in Code.
Specify the ActionBase.TargetObjectType, ActionBase.TargetViewType, ViewController.TargetObjectType, and ViewController.TargetViewType properties. Refer to the following topic for details: Define the Scope of Controllers and Actions.
Use the Conditional Appearance module. You can show and hide Actions based on the specified rules (for example, hide an Action based on business object properties). Refer to the following topic for more information: Declare Conditional Appearance Rules in Code. See the rule with the ActionState ID in the Examples section.
Use the Security System. You can define the Read, Write, Create, Delete, and Navigate permissions for business classes, objects, and members. Built-in Controllers display Actions according to these permissions. For example, the Delete Action is disabled if a user does not have permission to delete the selected objects.
You can manually specify permissions for custom and system Actions. Refer to the following link for more information: Action Permissions.
It is also possible to set permissions for custom Actions in code. For more information, refer to the following topics:
Specify the IModelView.AllowNew, IModelView.AllowDelete, IModelView.AllowEdit, and IModelCommonMemberViewItem.AllowClear properties in the Application Model. These properties define allowed operations with business objects in a View.
- Use the IModelHiddenActions node that allows you to hide an Action from a specific View in the Model Editor.