Skip to main content
A newer version of this page is available. .
All docs
V22.1
.NET Framework 4.5.2+

Manage the Visibility of Buttons Inside the Blazor Lookup Property Editor

  • 2 minutes to read

XAF manages the visibility of the New and Edit buttons inside the ASP.NET Core Blazor Lookup Property Editor according to Security System permissions, business object settings, and Action parameters.

The Edit and New buttons in the Blazor Lookup Property Editor

The following LookupPropertyEditor methods allow you to change the visibility of these buttons:

HideNewButton
Hides the New button.
HideEditButton
Hides the Edit button.
ResetNewButtonVisibility
Restores the default logic that displays the New button.
ResetEditButtonVisibility
Restores the default logic that displays the Edit button.

The following Controller demonstrates how to use Actions to manage the lookup editor button visibility:

File:
MySolution.Blazor.Server\Controllers\LookupActionVisibilityController.cs in solutions without the ASP.NET Core Blazor-specific Module project;
MySolution.Module.Blazor\Controllers\LookupActionVisibilityController.cs in solutions with the ASP.NET Core Blazor-specific Module project.

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.Blazor.Editors;
using DevExpress.Persistent.Base;
// ...
public class LookupActionVisibilityController : ViewController<DetailView> {
    public LookupActionVisibilityController() {
        SimpleAction hideNewAction = new SimpleAction(this, "Hide New", PredefinedCategory.Edit);
        SimpleAction hideEditAction = new SimpleAction(this, "Hide Edit", PredefinedCategory.Edit);
        SimpleAction resetNewAction = new SimpleAction(this, "Reset New", PredefinedCategory.Edit);
        SimpleAction resetEditAction = new SimpleAction(this, "Reset Edit", PredefinedCategory.Edit);
        hideNewAction.Execute += (s, e) => {
            View.CustomizeViewItemControl<LookupPropertyEditor>(this, e => {
                e.HideNewButton();
            });
        };
        hideEditAction.Execute += (s, e) => {
            View.CustomizeViewItemControl<LookupPropertyEditor>(this, e => {
                e.HideEditButton();
            });
        };
        resetNewAction.Execute += (s, e) => {
            View.CustomizeViewItemControl<LookupPropertyEditor>(this, e => {
                e.ResetNewButtonVisibility();
            });
        };
        resetEditAction.Execute += (s, e) => {
            View.CustomizeViewItemControl<LookupPropertyEditor>(this, e => {
                e.ResetEditButtonVisibility();
            });
        };
    }
}

If you do not need to create additional Actions as shown above, call HideNewButton and HideEditButton in the Controller’s OnActivated method to hide the New and Edit buttons unconditionally:

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Blazor.Editors;
// ...
public class LookupActionVisibilityController : ViewController<DetailView> {
    protected override void OnActivated() {
        base.OnActivated();
        View.CustomizeViewItemControl<LookupPropertyEditor>(this, e => {
            e.HideNewButton();
            e.HideEditButton();
        });
    }
}
See Also