Mendix Client 4 API Documentation


mxui.widget._Widget

mxui.widget._Widget is the object all widgets declared with mxui.widget.declare inherit of. The widget lifecycle documentation can be found here.

Properties

Widget properties should be accessed using the _Widget.set and _Widget.get functions.

content_id

The is the id of the content the widget is instantiated in.

disabled

Whether the widget is disabled; i.e. it is possible to change its value.

declaredClass

Full widget name, like “mxui.widget.DataGrid”.

className

The name of the widget, like “DataGrid”.

moduleName

The module name of the widget, like “mxui”.

Methods

addFocusBox(node)

This method is called to add a focus container to the widget.

Parameters

Name Type Description
node DOMNode The node which should act like a focus container.

Returns

Type Description
Box The focus container, to which focus nodes can be added.

getFocusBox(node)

This method is called to get the focus container associated to the give node.

Parameters

Name Type Description
node DOMNode The node which should act like a focus container.

Returns

Type Description
Box The focus container, to which focus nodes can be added.

addOnLoad(handler)

This method is called to add a function to be called when the widget is loaded.

Parameters

Name Type Description
handler Function Function to be called when the widget is loaded.

addOnDestroy(handler)

This method is called to add a function to be called when the widget gets destroyed.

Parameters

Name Type Description
handler Function Function to be called when the widget gets destroyed.

loaded()

This method is called to set the widget to loaded state, and run handlers added with addOnLoad.

actLoaded()

This method is called to set the widget to loaded state, run handlers added with addOnLoad, and call the callback (used for chains).

isLoaded()

This method is called to check whether the widget is loaded.

Returns

Type Description
Boolean true if the widget is loaded.

isLoadedRecursive()

This method is called to check whether the widget, and all nested widgets are loaded.

Returns

Type Description
Boolean true if the widget and all nested widgets are loaded.

update(mxobj, callback)

This method is called to update a widget when the context changed.

Parameters

Name Type Description
mxobj MxObject The main object in the context.
callback Function A function that must be called once the widget is finished.

applyContext(context, callback)

This method is called to apply a MxContext to a widget.

Parameters

Name Type Description
context MxContext The context to apply to the widget.
callback Function A function that must be called once the widget is finished.

applyContextRecursive(callback)

This method is called to apply the widget context to all children.

Parameters

Name Type Description
callback Function A function that must be called once the widget is finished.

callFetchOnChildren(context, children, callback)

This method is called to apply the given context to the given children.

Parameters

Name Type Description
context MxContext The context to apply to the children.
children Array The children to apply the context to.
callback Function Function to be called when all children are finished.

liveConnect(node, event, map)

This method is called to use event delegation on a number of nodes.

Parameters

Name Type Description
node DOMNode The node which is the parent of all target nodes.
event String The event to listen to.
map Object Map of node names and optional class names or id’s and a function to be called when the event occurs.

Returns

Type Description
Array Handler to remove the connect when passed to liveDisconnect.

Examples

this.liveConnect(tableNode, "mouseover", {
    "tr"          : onRowHover,
    "tr.selected" : onSelectionHover
});

liveDisconnect(handler)

This method is called to remove an event listener, added with liveConnect.

Parameters

Name Type Description
handler Array The return value of the liveConnect call.

suspend()

This method is called to suspend the widget when the form is closed.

resume()

This method is called to resume a suspended widget.

isSuspended()

This method is called to check whether a widget is suspended.

Returns

Type Description
Boolean true if the widget is suspended

subscribe()

Alias of mx.data.subscribe, but it also checks for redundant subscribes, and automatically removes all subscribes when the widget gets destroyed.

unsubscribe()

Alias of mx.data.unsubscribe.

removeSubscriptions()

Remove all subscriptions of this widget.

resizeContent()

Convenience function, see mxui.widget._Screen.resizeContent.

disposeContent()

Convenience function, see mxui.widget._Screen.disposeContent.

getContent()

This method is called to get the current contentid.

Returns

Type Description
String The contentid

getTitle()

Get the title of the containing form.

Returns

Type Description
String The title of the containing form

getUIPlace()

This method is called to get the current ui place of the widget (content, popup, modal).

Returns

Type Description
String The UI place

sequence(chain, callback)

This method is called to run a sequence of functions in widget scope. The next funtion in the chain is called when the previous function in the chain invoked its callback parameter.

Parameters

Name Type Description
chain Array Chainable functions which accept one parameter of type Function which is a callback to be invoked when finished

Examples

this.sequence([
    "getConstraints",
    "fetchPage",
    "renderPage"
], callback);

collect(collection, callback)

This method is called to run a collection of functions in widget scope. All functions in the collection are invoked at once, allowing multiple assynchronous requests at a time.

Parameters

Name Type Description
collection Array Collectable functions which accept one parameter of type Function which is a callback to be invoked when finished
callback Function Function to call when finished the chain.

Examples

this.collect([
    "fetchMetaData",
    "fetchUserData",
    "parseConfig"
], callback);

uninitialize()

This method is called when the widget gets destroyed.