Ticket T532233
Visible to All Users

Displaying only one action from an action category in a detail view

created 8 years ago

Hello,

I'm wondering what is the best way to add only one (or a subset of) action(s) from an action category to a detail view?

Say for example that I have a custom action under the Edit category. I want the action to be shown in the ribbon for all views but for some detail views, I want to have the action in in the view itself. However, I do not want to see any other action from the "Edit" category in the detail view. (I still want them in the ribbon so I cannot just add them to the hidden actions list).

Answers approved by DevExpress Support

created 8 years ago (modified 8 years ago)

Hello Hans,

You can hide unnecessary actions from an ActionContainerViewItem using the ActionControlsSiteController.CustomizeContainerActions and FillActionContainersController.CustomizeContainerActions events. Here is an example:

C#
using DevExpress.ExpressApp; using DevExpress.ExpressApp.Actions; using DevExpress.ExpressApp.SystemModule; using DevExpress.ExpressApp.Editors; using System.Collections.Generic; using System.Linq; namespace MainDemo.Module.Win { public class ActionLocationController : Controller { protected override void OnActivated() { base.OnActivated(); Frame.GetController<ActionControlsSiteController>().CustomizeContainerActions += ActionLocationController_CustomizeContainerActions; Frame.GetController<FillActionContainersController>().CustomizeContainerActions += ActionLocationController_CustomizeContainerActions; } void ActionLocationController_CustomizeContainerActions(object sender, DevExpress.ExpressApp.SystemModule.CustomizeContainerActionsEventArgs e) { if (e.Category == "Edit" && e.Container is ActionContainerViewItem) { List<ActionBase> actionsToRemove = e.ContainerActions.Where(a => a.Id != "Action1").ToList(); foreach (ActionBase action in actionsToRemove) { e.ContainerActions.Remove(action); } } } protected override void OnDeactivated() { base.OnDeactivated(); Frame.GetController<ActionControlsSiteController>().CustomizeContainerActions -= ActionLocationController_CustomizeContainerActions; Frame.GetController<FillActionContainersController>().CustomizeContainerActions -= ActionLocationController_CustomizeContainerActions; } } }

Refer to the ActionControlsSiteController.CustomizeContainerActions Event topic for additional information.

    Comments (1)

      Ok, thanks Anatol. I had hoped there was a "model editor" way of doing it, but this works as well.

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.