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 将恢复到其正常状态。

  • 相关阅读:
    atitit.解决struts2 SpringObjectFactory.getClassInstance NullPointerException
    atitit。 hb Hibernate sql 查询使用
    atitit.插件体系设计总结o73.doc
    Atitit.可视化编程jbpm6 的环境and 使用总结...
    paip.自动import的实现跟java.lang.SecurityException Prohibited package name java
    Linux下tar.xz结尾的文件的解压方法
    ubuntu下的Samba配置:使每个用户可以用自己的用户名和密码登录自己的home目录
    ubuntu Linux离线安装软件包
    C语言文件操作解析(一)[转载]
    PDF XChange Viewer文件关联
  • 原文地址:https://www.cnblogs.com/foreachlife/p/How-to-Disable-an-Action-When-the-Current-View-Has-Unsaved-Changes.html
Copyright © 2011-2022 走看看