zoukankan      html  css  js  c++  java
  • How to: Disable an Action When the Current View Has Unsaved Changes 如何:当前视图具有未保存的更改时禁用按钮

    This topic demonstrates how to disable an Action when business objects loaded to the current Object Space are changed. For this purpose, the IObjectSpace.ModifiedChanged event is handled, and the ActionBase.Enabled property is set based on the IObjectSpace.IsModified property.

    本主题演示如何在加载到当前对象空间的业务对象发生更改时禁用操作。为此,将处理 IObjectSpace.修改更改事件,并根据 IObjectSpace.IsModified 属性设置"操作基础"。

    Note 注意
    The approach described in this topic is not supported by the Mobile platform. If it is necessary to implement this scenario in your Mobile application, contact us using the Support Center
    移动平台不支持本主题中描述的方法。如果需要在移动应用程序中实施此方案,请使用支持中心与我们联系

    .

    public class ViewController1 : ViewController {
        SimpleAction action1;
        public ViewController1() {
            action1 = new SimpleAction(this, "Action1", DevExpress.Persistent.Base.PredefinedCategory.View);
        }
        protected override void OnActivated() {
            base.OnActivated();
            ObjectSpace.ModifiedChanged += ObjectSpace_ModifiedChanged;
            UpdateActionState();
        }
        void ObjectSpace_ModifiedChanged(object sender, EventArgs e) {
            UpdateActionState();
        }
        protected virtual void UpdateActionState() {
            action1.Enabled["ObjectSpaceIsModified"] = !ObjectSpace.IsModified;
        }
        protected override void OnDeactivated() {
            base.OnDeactivated();
            ObjectSpace.ModifiedChanged -= ObjectSpace_ModifiedChanged;
        }
    }

    As a result, the Action1 is grayed out in the UI when there are unsaved changes in the current View. It is impossible to execute the Action until changes are saved to a data store (e.g., using the Save Action). When the changes are saved, the Action1 reverts to its normal state.

    因此,当当前视图中存在未保存的更改时,操作 1 在 UI 中显示为灰色。在将更改保存到数据存储(例如,使用保存操作)之前,无法执行操作。保存更改后,Action1 将恢复到其正常状态。

  • 相关阅读:
    销傲中国式销售过程管理系统功能概述
    真正高效的SQLSERVER分页查询(多种方案)
    request.getScheme()的使用方法
    用户'sa'登录失败(错误18456)解决方案图解
    在SQL Server中创建用户角色及授权
    大话设计模式--外观模式 Facade -- C++实现实例
    大话设计模式--模板方法模式 TemplateMethod -- C++ 实现
    大话设计模式--原型模式 Prototype -- C++实现
    C++拷贝构造函数(深拷贝,浅拷贝)
    大话设计模式--工厂方法模式 Factory Method -- C++实现
  • 原文地址:https://www.cnblogs.com/foreachlife/p/How-to-Disable-an-Action-When-the-Current-View-Has-Unsaved-Changes.html
Copyright © 2011-2022 走看看