1.3.5. 动态表单 - 加载与关闭
金蝶云社区-云小爱
云小爱
1人赞赏了该文章 3,860次浏览 未经作者许可,禁止转载编辑于2014年04月02日 17:06:25
加载和关闭OnLoad页面加载。该事件在BeforeBindData前触发,并且不受StyleManager管理,在此事件设置单据字段的可见性和锁定性无效。OnLoad时,数据已经获取到,通常我们在此事件处理一些数据设置。 例如:过滤界面插件设置缺省值和页签可见性。
[tr][td]C#[td]
[tr][td=2,1]public class SaleCollectFilter : AbstractCommonFilterPlugIn {public override void OnLoad(EventArgs e){base.OnLoad(e);//设置日期缺省值 this.View.Model.SetValue("FStartDate", dateFrom.ToString("yyyy-MM-dd"));this.View.Model.SetValue("FEndDate", dateTo.ToString("yyyy-MM-dd"));//隐藏过滤界面排序页签this.View.StyleManager.SetVisible("FTab_P21", null, false);}}
列表界面隐藏分组滑动控件。
[tr][td]C#[td]
[tr][td=2,1]public class SPMPromotionPolicyList : AbstractListPlugIn{ public override void OnLoad(EventArgs e) { base.OnLoad(e); // 隐藏分组滑动控件(默认不展开) this.View.GetControl("FSpliter").HideFirstPanel(true);this.View.GetControl("FPanel").SetCustomPropertyValue("BackColor", "#FFEEEEEE"); }}
注:该事件在每次UpdateView()时候都会调用。 BeforeClosed页面关闭前插件。对于单个表单关闭,该插件基本不需要处理。对于多个表单交互,或者嵌入式表单,通常需要关闭窗体时,返回数据时,通过该插件实现。如:关闭时刷新父窗体。
[tr][td]C#[td]
[tr][td=2,1]public override void BeforeClosed(BeforeClosedEventArgs e){ object isDataChanged = this.View.OpenParameter.GetCustomParameter("Changed"); if (isDataChanged != null && (bool)isDataChanged) { this.View.ParentFormView.Refresh(); this.View.SendDynamicFormAction(this.View.ParentFormView);} base.BeforeClosed(e);}
关闭时传递数据到父窗体。
[tr][td]C#[td]
[tr][td=2,1]public override void BeforeClosed(BeforeClosedEventArgs e){this.View.ReturnToParentWindow(_data); base.BeforeClosed(e);}
关闭窗体判断数据是否修改并提示保存。
[tr][td]C#[td]
[tr][td=2,1]/// /// 界面关闭前事件:判断用户是否修改了数据,提示保存/// /// public override void BeforeClosed(BeforeClosedEventArgs e){ if (this._dataChanged == true) // 仅关注模型数据发生了改变的情况 { e.Cancel = true; string msg = "内容已经修改,是否保存?"; this.View.ShowMessage(msg, MessageBoxOptions.YesNoCancel, new Action((result) => { if (result == MessageBoxResult.Yes) // 保存 { this.View.GetControl("FDesignPanel").InvokeControlMethod("Save"); } else if (result == MessageBoxResult.No) // 不要保存 { this._dataChanged = false; this.View.Close(); } })); }}