Caplin Trader 5.1.0

Interface: module:ct-element/RendererFramework

module:ct-element/RendererFramework

The ControlFramework interface specifies those lifecycle functions that are necessary for a control implementation to be managed by the Control Framework.

Methods

bind(controlElement)

Binds the renderer to the DOM and attaches any event listeners to the control.

Parameters:
Name Type Description
controlElement HTMLElement

The DOM element representing the renderer

See:

createHtml(fieldValues, className) → {HtmlElement|DocumentFragment}

Returns an HTMLElement (or DocumentFragment) that defines this element.

This is the first of two steps required to bind a renderer to its corresponding HTML element. In fact, there are two ways of binding a renderer:

  1. The simplest way is to use the module:ct-element/RendererFramework#getElement helper method — this invokes createHtml() and module:ct-element/RendererFramework#bind on your behalf.
  2. A more performant mechanism for components that contain large numbers of renderers is to use invoke module:ct-element/RendererFramework#createHtml and module:ct-element/RendererFramework#bind yourself, so that the entire DOM strucutre for all renderers can be created using a single use call to appendChild, allowing significant performance gains to be achieved.

This method must be called after the FieldModel has been set using FieldModel.setFieldModel(). If the FieldModel is populated with some initial data for this renderer, then the HTML fragment returned will also contain that value, obviating the need for an call to module:ct-element/Renderer#setValue afterwards.

Parameters:
Name Type Description
fieldValues Map

The field values

className string

The HTML class attribute (a space separated list)

See:
Returns:

The HTML fragment.

Type
HtmlElement | DocumentFragment

finalize()

Releases any renderer resources and resets its state.

getAllFieldNames() → {Array}

Returns a complete list of all field names that the renderer depends on.

Returns:

The field names.

Type
Array

getElement() → {Element}

Returns the element that this renderer is associated with.

If the renderer binding was not performed manually using module:ct-element/RendererFramework#createHtml and module:ct-element/RendererFramework#bind, then this helper method will do this automatically on your behalf.

See:
Returns:

The element associated with this renderer.

Type
Element

getPrimaryFieldNames() → {Array.<string>}

Returns a list of primary fields.

Returns:

The field names.

Type
Array.<string>

getSerialId() → {string}

Returns the serial id of the renderer instance.

Returns:

The renderer serial id.

Type
string

initialize(initialFieldValues)

Initializes the renderer and sets its state according to the supplied field values.

Parameters:
Name Type Description
initialFieldValues Map

The initial field values

isBound() → {boolean}

Returns true if the renderer has been bound to the DOM.

See:
Returns:

True if the renderer has been bound to the DOM, or false otherwise.

Type
boolean

setName(name)

Sets the renderer's name.

Parameters:
Name Type Description
name string

The renderer's name.

setNamespace(namespace)

Sets the renderer's namespace.

Parameters:
Name Type Description
namespace string

The renderer's namespace.

unbind()

Unbinds the renderer from the DOM and detaches any event listeners to the control.

See: