dojox/mvc/Bind.ListController (version 1.10)

dojox/mvc/ModelRefController

Summary

A controller working with array model, managing its cursor. NOTE - If this class is used with a widget by data-dojo-mixins, make sure putting the widget in data-dojo-type and putting this class to data-dojo-mixins.

See the dojox/mvc/Bind.ListController reference documentation for more information.

Examples

Example 1

The text box changes its value every two seconds.

<html>
    <head>
        <script src="/path/to/dojo-toolkit/dojo/dojo.js" type="text/javascript" data-dojo-config="parseOnLoad: 0"></script>
        <script type="text/javascript">
            require([
                "dojo/parser", "dijit/registry", "dojox/mvc/StatefulArray",
                "dijit/form/TextBox", "dojox/mvc/ListController", "dojo/domReady!"
            ], function(parser, registry, StatefulArray){
                var count = 0;
                model = new StatefulArray([{value: "First"}, {value: "Second"}, {value: "Third"}, {value: "Fourth"}, {value: "Fifth"}]);
                setInterval(function(){ registry.byId("ctrl").set("cursorIndex", ++count % 5); }, 2000);
                parser.parse();
            });
        </script>
    </head>
    <body>
        <script type="dojo/require">at: "dojox/mvc/at"</script>
        <span id="ctrl" data-dojo-type="dojox/mvc/ListController" data-dojo-props="model: model"></span>
        <input type="text" data-dojo-type="dijit/form/TextBox" data-dojo-props="value: at('widget:ctrl', 'value')">
    </body>
</html>

Property Summary

  • _attrPairNamesUsed across all instances a hash to cache attribute names and their getter and setter names.
  • _listModelWatchHandleThe watch handle of model, watching for array elements.
  • _refCursorPropThe property name for the data model of the current selection.
  • _refInModelPropThe property name for the data model, used as the input.
  • _refModelPropThe property name for the data model.
  • _tableModelWatchHandleThe watch handle of model.
  • cursorThe selected element in the model array.
  • cursorIdThe ID of the selected element in the model array.
  • cursorIndexThe index of the selected element in the model.
  • data-mvc-bindings
  • dataBindAttrThe attribute name for data binding.
  • idPropertyThe property name in element in the model array, that works as its identifier.
  • modelThe data model working as an array.
  • ownPropsList of property names owned by this controller, instead of the data model.

Method Summary

  • _changeAttrValue(name,value) Internal helper for directly changing an attribute value.
  • _dbpostscript(params,srcNodeRef) See if any parameters for this widget are dojox/mvc/at handles.
  • _get(name,names) Private function that does a get based off a hash of names
  • _getAttrNames(name) Helper function for get() and set().
  • _getExcludesAttr() Returns list of all properties that data binding is established with.
  • _getPropertiesAttr() Returns list of all properties in this widget, except "id".
  • _set(name,value) Set the value to the data model or to this object.
  • _setAtWatchHandle(name,value) Called if the value is a dojox/mvc/at handle.
  • _setBind(value) Sets data binding described in data-mvc-bindings.
  • _setCursorIdAttr(value) Handler for calls to set("cursorId", val).
  • _setCursorIndexAttr(value) Handler for calls to set("cursorIndex", val).
  • _startAtWatchHandles(bindWith) Establish data bindings based on dojox/mvc/at handles.
  • _stopAtWatchHandles() Stops data binding synchronization handles as widget is destroyed.
  • destroy()
  • get(name) If getter function is there, use it.
  • hasControllerProperty(name) Returns true if this controller itself owns the given property.
  • postscript(params,srcNodeRef) Sets _relTargetProp so that the property specified by _refModelProp is used for relative data binding.
  • set(name,value) Set a property to this.
  • startup() Starts up data binding as this object starts up.
  • watch(name,callback) Watch a property in the data model or in this object.

Properties

_attrPairNames
Defined by: dojo/Stateful

Used across all instances a hash to cache attribute names and their getter and setter names.

_listModelWatchHandle

The watch handle of model, watching for array elements.

_refCursorProp

The property name for the data model of the current selection.

_refInModelProp

The property name for the data model, used as the input. Used when this controller needs data model (as input) that is different from the data model this controller provides.

_refModelProp

The property name for the data model.

_tableModelWatchHandle

The watch handle of model.

cursor

The selected element in the model array.

cursorId

The ID of the selected element in the model array.

cursorIndex

The index of the selected element in the model.

data-mvc-bindings
dataBindAttr

The attribute name for data binding.

idProperty

The property name in element in the model array, that works as its identifier.

model

The data model working as an array.

ownProps

List of property names owned by this controller, instead of the data model.

Methods

_changeAttrValue(name,value)
Defined by dojo/Stateful

Internal helper for directly changing an attribute value.

Directly change the value of an attribute on an object, bypassing any accessor setter. Also handles the calling of watch and emitting events. It is designed to be used by descendant class when there are two values of attributes that are linked, but calling .set() is not appropriate.

Parameter Type Description
name String

The property to set.

value Mixed

The value to set in the property.

Returns:function

Internal helper for directly changing an attribute value.

_dbpostscript(params,srcNodeRef)

See if any parameters for this widget are dojox/mvc/at handles. If so, move them under this._refs to prevent widget implementations from referring them.

Parameter Type Description
params Object
Optional
srcNodeRef DomNode | String
_get(name,names)
Defined by dojo/Stateful

Private function that does a get based off a hash of names

Parameter Type Description
name undefined
names undefined

Hash of names of custom attributes

Returns:undefined
_getAttrNames(name)
Defined by dojo/Stateful

Helper function for get() and set(). Caches attribute name values so we don't do the string ops every time.

Parameter Type Description
name undefined
Returns:undefined | object
_getExcludesAttr()

Returns list of all properties that data binding is established with.

Returns:undefined | Array
_getPropertiesAttr()

Returns list of all properties in this widget, except "id".

Returns:String[] | undefined

The list of all properties in this widget, except "id"..

_set(name,value)

Set the value to the data model or to this object.

Parameter Type Description
name String

The property name.

value Anything

The property value.

Returns:function | undefined

Set the value to the data model or to this object.

_setAtWatchHandle(name,value)

Called if the value is a dojox/mvc/at handle. If this widget has started, start data binding with the new dojox/mvc/at handle. Otherwise, queue it up to this._refs so that _dbstartup() can pick it up.

Parameter Type Description
name String
value Anything
_setBind(value)

Sets data binding described in data-mvc-bindings.

Parameter Type Description
value Object
_setCursorIdAttr(value)

Handler for calls to set("cursorId", val).

Finds the index associated with the given cursor ID, and updates cursorIndex property.

Parameter Type Description
value String
_setCursorIndexAttr(value)

Handler for calls to set("cursorIndex", val).

Updates cursor, cursorId, cursorIndex properties internally and call watch callbacks for them.

Parameter Type Description
value Number
_startAtWatchHandles(bindWith)

Establish data bindings based on dojox/mvc/at handles.

Parameter Type Description
bindWith dojo/Stateful

The dojo/Stateful to bind properties with.

_stopAtWatchHandles()

Stops data binding synchronization handles as widget is destroyed.

destroy()
get(name)

If getter function is there, use it. Otherwise, get the data from data model of this object.

Parameter Type Description
name String

The property name.

Returns:undefined
hasControllerProperty(name)

Returns true if this controller itself owns the given property.

Parameter Type Description
name String

The property name.

Returns:boolean
postscript(params,srcNodeRef)

Sets _relTargetProp so that the property specified by _refModelProp is used for relative data binding.

Parameter Type Description
params Object
Optional
srcNodeRef DomNode | String
Optional
set(name,value)

Set a property to this.

Parameter Type Description
name String

The property to set.

value Anything

The value to set in the property.

startup()

Starts up data binding as this object starts up.

watch(name,callback)

Watch a property in the data model or in this object.

Parameter Type Description
name String
Optional

The property name.

callback Function

The callback function.

Returns:undefined | object
Error in the documentation? Can’t find what you are looking for? Let us know!