重寫controller的CloseAndSave方法(點擊關閉時關閉整個Detail View)

Override Controller Behavior

using DevExpress.ExpressApp.Web.SystemModule;
using MySolution.Module.BusinessObjects;
// ...
public partial class MyWebDetailViewController : WebDetailViewController {
    public MyWebDetailViewController() {
        InitializeComponent();
        RegisterActions(components);
    }
    protected override void SaveAndClose(SimpleActionExecuteEventArgs e) {
        View view = View;
        base.SaveAndClose(e);
        if ((view != null) && (((DetailView)view).ObjectTypeInfo.Type == typeof(Contact))) {
            view.Close();
        }
    }
}

  • With this code, the SaveAndClose Action will close the current Detail View only if it displays a Contact object. You should always use the demonstrated approach to customize a built-in Controller behavior for a particular View or business class instead of changing the Controller's TargetObjectType, TargetViewType, TargetViewId and TargetViewNesting properties. Otherwise, you will lose the functionality of the inherited Controller in other Views. 


發佈了33 篇原創文章 · 獲贊 4 · 訪問量 9萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章