How to: Customize the New Action's Items List How to: Customize the list of items the new button

This topic demonstrates how to access the list of business classes added to the NewObjectViewController.NewObjectAction items list in WinForms and ASP.NET applications with the Classic Web UI.

This topic demonstrates how to access a list of items to add to the business class of NewObjectViewController.NewObjectAction, and listed in the WinForms and ASP.NET use the classic Web UI application.

 

Generally, you can use the NewObjectViewController.NewObjectActionItemListMode property to choose the predefined mode of populating the New Action item list. If modes listed in the NewObjectActionItemListMode enumeration do not fit your requirements, proceed to see how to populate the list manually.

Typically, you can use selective filling properties NewObjectViewController.NewObjectActionItemListMode "New Action Item" item predefined pattern list. If the mode NewObjectActionItemListMode enumeration listed does not meet your requirements, please continue to learn how to manually populate the list.

 

To customize the New Action's Items list, handle the NewObjectViewController.CollectDescendantTypes and NewObjectViewController.CollectCreatableItemTypes events of the NewObjectViewController, which contains the New Action. The former event is raised when the current object type and its descendants are added to the Action's Items list, and the latter is raised when all the remaining types whose CreatableItem property is set to true in the Application Model (see IModelBOModel) are added. In the example below, the Task item is removed.

To customize the "new operation" item list, please deal with the "new view controller objects": collect child object types and NewObjectView controller. The collection includes "a new view controller objects" actionable item type events. When the property is set after CreatableItem add application model for all other types of true (See IModelBOModel), will trigger; when the current object types and their offspring added to the "item" list of actions, the trigger event before a an event. In the following example, the task item will be deleted.

Note Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-customize-the-new-actions-items-list-e238
The complete sample project can https://github.com/DevExpress-Examples/how-to-customize-the-new-actions-items-list-e238

.

  • CustomizeNewActionItemsListController.cs
  • CustomizeNewActionItemsListController.vb
  • Custom control .vb new action item list
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.ExpressApp;
using DevExpress.Persistent.BaseImpl;
using DevExpress.ExpressApp.SystemModule;

namespace CustomizeNewActionItemsListExample.Module.Controllers {
    public class CustomizeNewActionItemsListController : ObjectViewController<ObjectView, Task> {
        protected override void OnActivated() {
            base.OnActivated();
            NewObjectViewController controller = Frame.GetController<NewObjectViewController>();
            if (controller != null) {
                controller.CollectCreatableItemTypes += NewObjectViewController_CollectCreatableItemTypes;
                controller.CollectDescendantTypes += NewObjectViewController_CollectDescendantTypes;
                if (controller.Active) {
                    controller.UpdateNewObjectAction();
                }
            }
        }
        private void NewObjectViewController_CollectDescendantTypes(object sender, CollectTypesEventArgs e) {
            CustomizeList(e.Types);
        }
        private void NewObjectViewController_CollectCreatableItemTypes(object sender, CollectTypesEventArgs e) {
            CustomizeList(e.Types);
        }
        private void CustomizeList(ICollection<Type> types) {
            List<Type> unusableTypes = new List<Type>();
            foreach (Type item in types) {
                if (item == typeof(Task)) {
                    unusableTypes.Add(item);
                }
            }
            foreach (Type item in unusableTypes) {
                types.Remove(item);
            }
        }
        protected override void OnDeactivated() {
            NewObjectViewController controller = Frame.GetController<NewObjectViewController>();
            if (controller != null) {
                controller.CollectCreatableItemTypes -= NewObjectViewController_CollectCreatableItemTypes;
                controller.CollectDescendantTypes -= NewObjectViewController_CollectDescendantTypes;
            }
            base.OnDeactivated();   
        }
    }
 }

 

Guess you like

Origin www.cnblogs.com/foreachlife/p/How-to-Customize-the-New-Action-s-Items-List.html