Widget not applying context constraint

7
This is my first week of mendix so bear with me. I'm writing a 'Collapsible Panel' widget similar to the 'Form Loader' widget, with the addition of a header that collapses the panel/loaded form. Domain Model => Person(1) <- (*)Alias. Main Form => Has a Person data grid and below it a person data view (which has the data grid as its listen target) which contains the 'Form Loader' widget as well as my 'Collapsible Panel' widget. Widget Form => Has a data view at the root with entity type Person, containing a data grid of Alias (with 'Apply context' set to true). The problem I am having is that my widget does not apply the constraint of the Person to the Alias(es). This does work for the 'Form Loader' widget. Widget javascript: applyContext : function(context, callback) { if (context && context.getActiveGUID()) { this.cloneContext(context); this.addFormToPanelContent(); } else console.log(this.id + ".applyContext did not receive a context"); callback && callback(); }, addFormToPanelContent : function() { var ioBind = mxui.lib.putContent(this.form, {}, this.panelContent); ioBind.addCallback(dojo.hitch(this, function () { this.formObj = dijit.byNode(this.panelContent.childNodes[0].childNodes[0]); this.applyContextToForm(); })); }, applyContextToForm : function() { var ctxt = this.createContext() .setContext(this.mxcontext.getActiveClass(), this.mxcontext.getActiveGUID()); this.formObj.applyContext(ctxt, dojo.hitch(this, function() { console.log(this.id + ".applyContextToFrom => context applied"); })); } Any help and extra insights is highly appreciated, Thanks in advance.
asked
2 answers
3

Hi Marlo,

It looks like you are trying to chain the create and set context functions. This is not possible in Dojo without an extra function.

I'd advise you do it as the Form Loader does it:

var ctxt = this.createContext();
ctxt.setTrackObject(this.mxcontext.getTrackObject());

(getTrackObject is new in 3.0)

answered
5

Got it working.

Works with:

applyContextToForm : function() {
    var ctxt = this.createContext();
    ctxt.setContext(this.mxcontext.getActiveClass(), this.mxcontext.getActiveGUID());

    this.formObj.applyContext(ctxt, dojo.hitch(this, function() {
    console.log(this.id + ".applyContextToFrom => context applied");
}));

}

So the unchaining fixed it, thank you.

Still wondering why the 3.0 call (getTrackObject()) returned a ctxt that does not have values assigned to its 'trackId' and 'trackClass'.

answered