Back to Devexpress

Manage Button Visibility in a Blazor Lookup Property Editor

expressappframework-403870-ui-construction-view-items-and-property-editors-property-editors-manage-the-visibility-of-buttons-inside-the-blazor-lookup-property-editor.md

latest4.5 KB
Original Source

Manage Button Visibility in a Blazor Lookup Property Editor

  • Nov 03, 2025
  • 2 minutes to read

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

Lookup Property Editor in a Detail View Lookup Property Editor in a List View with in-place editing enabled

Call the following LookupPropertyEditor methods to hide or display these buttons:

HideNewButtonHides the New button.HideEditButtonHides the Edit button.ResetNewButtonVisibilityDisplays the hidden New button.ResetEditButtonVisibilityDisplays the hidden Edit button.

Note

The Edit button acts as a clickable link. Use Ctrl + click or click the middle mouse button to open the referenced object in a new browser tab. To disable this behavior, add a Controller to your application, as described in the following topic: Hide Hyperlinks in Lookup Controls.

In a Detail View

The following code snippet uses Actions to manage lookup editor button visibility:

File :
MySolution.Blazor.Server\Controllers\LookupActionVisibilityController.cs

csharp
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 in the code sample above, call HideNewButton and HideEditButton in the Controller’s OnActivated method to hide the New and Edit buttons unconditionally.

Note

These changes will apply to Detail View and List View when in-place editing is enabled. To apply the changes for a particular View, use the CustomizeViewItemControl<T>(View, Controller, Action<T>) method.

File :
MySolution.Blazor.Server\Controllers\LookupActionVisibilityController.cs

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

See Also

How to: Detect a Lookup List View in Code