Ticket T254827
Visible to All Users

How to explicitly define actions for specific container using controller?

created 10 years ago

I'm currently dealing with situation I'll try to describe:
- I have set of General actions. This set consist of my own common actions implemented in independent module and DevExpress standard actions).
- This actions are available more or less for each ListView.
- However there are many specific ListViews where only particular subset of this General actions should be available (subset differs for each such a ListView).

I already evaluated solution, where HideAction node of application model would be used. However, this is not an option since I would be forced to update all the nodes (hundreds) in application every time any new action is added.

One way I found suitable is to manage actions in appropriate controller. I would prepare single-purpose container in my templates called FeaturedActions (for instance) and I would assign required actions to this container in runtime. Unfortunately I did not figure out, how to manage actions in such a way.

I was also thinking about someting like to iterate over all the active actions for particular controller and deactivate all the actions except required ones. However I'm affraid I can't simly deactivate all the other actions, since they can be important for regular work with listview and currently are just available in different containers (context menu, sidebar etc.).

Nevertheless I'm not sure this is the best approach anyway.

Thank you for your advice.

Answers approved by DevExpress Support

created 10 years ago (modified 10 years ago)

Hello Svatopluk,

I totally agree with you that it is much easier to display a specific Action in the required View only instead of hiding it everywhere manually. I also agree that it is better to approach this via a custom Controller programmatically.
You can manage a location of actions within the ActionContainer in code by using the events of the FillActionContainersController class. For instance, the Disable New action, but not Save&New ticket (as a few others in our support database) demonstrates how to handle the CustomizeContainerActions event for that purpose.
Regardless, it seems to me that it will be much easier for you to simply set the ActionBase.TargetViewId property to required View identifiers to make sure your Actions are only available in them. What do you think?

    Comments (2)
    SU SU
    Svatopluk Ulicny 10 years ago

      FillActionContainersController class solves it perfectly.
      Thanks a lot.

      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.