我是 X++ 的新手,我想在销售标题表单 (SalesTable) 的选项卡上放置一个未绑定的复选框。当在销售行表单的下半部分按下配置行按钮时,我需要让其他类中的代码检查 SalesTable 表单中未绑定控件的开/关状态并执行一些操作。我真的不需要数据库来记录状态。
当前状态是我已经在表单上放置了复选框,在显示屏上看到它并可以单击它,但无法引用它。
如何从另一个类引用 SalesTable 表单中的未绑定控件,这是正确的方法吗?
You don't refer to the unbound control from another class, it is not the right approach.
Rather inform the other class when the unbound control is changed. You do that in the modified method of the checkbox control:
boolean modified()
{
boolean ret = super();
;
salesTableForm.parmSpecialAction(this.value());
return ret;
}
In this case the SalesTableForm
is informed of the change of the checkbox by calling a method parmSpecialAction
(name arbitrarily chosen).
The other route (you indicated in the question) would be to inform the class about the existence of the control and let the class call control.value()
directly. However this will usually make the form and the class tightly coupled, which is not what we want. The controls belongs to the form where they were born and should not be passed around.
Ironically the SalesTableForm.enableUpdateJournalButtons
method violates this rule, as it accepts button controls as parameters. The correct approach would be to calculate (and cache) the enableWathever
values in getter functions, then let the form call the getters and enable or disable its own buttons.