zoukankan      html  css  js  c++  java
  • How to: Customize the New Action's Items List 如何:自定义新按钮的项目列表

    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.

    本主题演示如何访问添加到 NewObjectViewController.NewObjectAction 项目列表的业务类,并在 WinForms 中列出,并ASP.NET使用经典 Web UI 的应用程序。

    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.

    通常,您可以使用 NewObjectViewController.NewObjectActionItemListMode 属性选择填充"新建操作项"项列表的预定义模式。如果 NewObjectActionItemListMode 枚举中列出的模式不符合您的要求,请继续了解如何手动填充列表。

    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.

    要自定义"新操作"的项目列表,请处理"新对象视图控制器":收集子对象类型和 NewObjectView 控制器。收集包含"新对象视图控制器"的可操作项类型事件。当当前对象类型及其后代添加到操作的"项"列表中时,将引发前一个事件;当添加应用程序模型中的 CreatableItem 属性设置为 true 的所有其余类型(请参阅 IModelBOModel)时,将引发后一个事件。在下面的示例中,任务项将被删除。

    Note 注意
    A complete sample project is available at https://github.com/DevExpress-Examples/how-to-customize-the-new-actions-items-list-e238
    完整的示例项目可在https://github.com/DevExpress-Examples/how-to-customize-the-new-actions-items-list-e238

    .

    • CustomizeNewActionItemsListController.cs
    • CustomizeNewActionItemsListController.vb
    • 自定义新操作项列表控制器.vb
    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();   
            }
        }
     }
  • 相关阅读:
    被.net郁闷的一天
    使用批处理出现奇怪的现象
    我们应该更相信ghost
    asp.net设置默认按钮的一种方法(041217更新)
    asp中access到sql server导入升级后要做的工作。
    一种简单方便的权限控制方案
    为何我的本本不能打开休眠功能?
    祝贺自己的blog开张
    sql server中分页获取数据的存储过程
    httpcompress实际效果能有多少?
  • 原文地址:https://www.cnblogs.com/foreachlife/p/How-to-Customize-the-New-Action-s-Items-List.html
Copyright © 2011-2022 走看看