Ticket T472989
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

How to remove or hide the base class from the New Action's items list

HCategory appears under NewAction

created 8 years ago

I have a class, Kategori , which inherits from HCategory.
If I open a detail view the new action on the Children tab shows both HCategory and Kategori.

If i select new from the TreeListEditor it only shows Kategori.

I tried the approach suggested here: https://www.devexpress.com/Support/Center/Question/Details/Q108244

C#
public partial class HideHCategoryViewController : ViewController { public HideHCategoryViewController() { InitializeComponent(); // Target required Views (via the TargetXXX properties) and create their Actions. //RegisterActions(components); this.TargetViewId = "HCategory_Children_ListView"; } protected override void OnActivated() { base.OnActivated(); // Perform various tasks depending on the target View. Frame.GetController<NewObjectViewController>().CollectCreatableItemTypes += HideHCategoryViewController_CollectCreatableItemTypes; Frame.GetController<NewObjectViewController>().CollectDescendantTypes += HideHCategoryViewController_CollectDescendantTypes; } private void HideHCategoryViewController_CollectDescendantTypes(object sender, CollectTypesEventArgs e) { foreach (var item in e.Types) { if (item.GetType() == typeof(HCategory)) { e.Types.Remove(item); } } } private void HideHCategoryViewController_CollectCreatableItemTypes(object sender, CollectTypesEventArgs e) { foreach (var item in e.Types) { if(item.GetType() == typeof(HCategory)) { e.Types.Remove(item); } } } protected override void OnViewControlsCreated() { base.OnViewControlsCreated(); // Access and customize the target View control. //Frame.GetController<NewObjectViewController>().CollectCreatableItemTypes += HideHCategoryViewController_CollectCreatableItemTypes; //Frame.GetController<NewObjectViewController>().CollectDescendantTypes += HideHCategoryViewController_CollectDescendantTypes; } protected override void OnDeactivated() { // Unsubscribe from previously subscribed events and release other references and resources. base.OnDeactivated(); } }

If i put breakpoints in the two event handlers it never enters them.

Commenting out

C#
this.TargetViewId = "HCategory_Children_ListView";

does nothing.

Moving

C#
Frame.GetController<NewObjectViewController>().CollectCreatableItemTypes += HideHCategoryViewController_CollectCreatableItemTypes; Frame.GetController<NewObjectViewController>().CollectDescendantTypes += HideHCategoryViewController_CollectDescendantTypes;

to OnViewControlsCreated is not doing anything neither.

Any suggestions?

Terje

Comments (1)
TI TI
Terje Innerdal 8 years ago

    Forgot to add screenshot

    Answers approved by DevExpress Support

    created 8 years ago (modified 8 years ago)

    Hello Terje,

    It is important to follow the approach with inheritance demonstrated in the original article to be able to catch the required events for the root and nested context. Take special note that if you are showing the Kategori_ListView directly in the navigation control (i.e. do not show HCategory_ListView), you do not need to perform this customization for the root View. Assuming that you have implemented it this way, find two attached files, which demonstrate a modified Task-Based Help > How to: Customize the New Action's Items List  approach for your particular case with nested ListView. Please let me know how this works for you or if there any questions.

      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.