Every UI Toolkit control has events (On click, On change, On row selected, On load, ...) whose value is JavaScript that the framework runs with the control as me. To connect a function of your own coach view, expose the function on the view and call it from the event text with control addressing:
// 1. In your coach view "OrderTools" (the parent that contains the toolkit controls), load handler:
var _this = this;
this.recalc = function (source) {
var lines = _this.ui.get("Lines").getData() || [];
var total = lines.reduce(function (s, l) { return s + (l.qty || 0) * (l.price || 0); }, 0);
_this.ui.get("Total").setData(total);
if (source) console.log("recalc triggered by", source.context.viewid);
};
// 2. In the toolkit control's event (e.g. Decimal "Price" inside the table > On change):
// address the parent view and call its function; "me" is the control that fired
me.ui.getParent ? me.ui.getParent().recalc(me) : page.ui.get("OrderTools").recalc(me);
// shorter when the parent id is known: ${OrderTools}.recalc(me)Three details: (a) functions must be attached to the view object (this.recalc = ...), not declared with function recalc() - the latter is invisible outside the handler; (b) inside a repeating table the control's path includes the row, so use relative addressing (me.ui.get("../../Total")) or the parent lookup; (c) for the reverse direction - a coach view listening to a control - keep the wiring in the control's event text as shown, or attach a DOM listener to the control's element (${Price}.context.element.addEventListener("change", ...)).
References