开发者

X++ unbound control

I'm new to X++, and I want to put an unbound checkbox on a tab in the sales header form (SalesTable). When the configure line button is pressed on the bottom half of the form for a sales line, I need to have code in that other class check the on/off status of the unbound control in the SalesTable form and do something. I really don't need the database to record the status.

The current status is I've placed the checkbox on the form, see it on the display and can click it, but can't refer to it.

开发者_如何学Go

How do I refer to the unbound control in the SalesTable form from another class and, is this the right approach?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜