Caplin Trader 5.1.0

Class: module:ct-element/renderer/StreamRenderer

module:ct-element/renderer/StreamRenderer(rendererType, primaryFieldNames, control)

new module:ct-element/renderer/StreamRenderer(rendererType, primaryFieldNames, control)

StreamRenderer is an abstract base class, therefore this constructor should not be directly invoked.

Instead, the RendererFactory should be used to create instances, which requires the RendererTypes to have been declared in XML and loaded using the RendererTypeLoader.

Parameters:
Name Type Description
rendererType module:ct-element/factory/RendererType

The renderer type.

primaryFieldNames Array.<string>

The list of model field names.

control module:ct-control/Control

An instance of the screen control.

Implements:

Methods

addRendererEventListener(rendererEventListener)

Adds a module:ct-element/RendererEventListener to which the Renderer will communicates user-gestures.

Parameters:
Name Type Description
rendererEventListener module:ct-element/RendererEventListener

The renderer event listener.

Implements:

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

Implements:
See:

bindHandlers()

Binds event listeners to the control for all the handlers, which will result in a callbacks to the onRendererEvent() method then any event occurs.

clear()

Clears the renderer value and all associated state, including the displayed value. The renderer will remain bound to the DOM.

Implements:

clearState()

Clears the renderer state without clearing the displayed value. This is a performant version of clear for when you are going to update the displayed value immediately after clearing.

Implements:

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)

Implements:
See:
Returns:

The HTML fragment.

Type
HtmlElement | DocumentFragment

disable()

Disables the renderer control. Does nothing if the control has no concept of enabled/disabled.

Implements:

enable()

Enables the renderer control. Does nothing if the control has no concept of enabled/disabled.

Implements:

finalize()

Releases any renderer resources and resets its state.

Implements:

focus()

Moves the focus to this renderer. Does nothing if the control has no concept of focus.

Implements:

getAllFieldNames() → {Array}

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

Implements:
Returns:

The field names.

Type
Array

getControl() → {module:ct-control/Control}

Returns a control corresponding to the renderer.

Returns:

The control

Type
module:ct-control/Control

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.

Implements:
See:
Returns:

The element associated with this renderer.

Type
Element

getFieldValues() → {Map}

Returns the fields relating to the currently displayed value.

Implements:
Returns:

The field values.

Type
Map

getFormattedValue() → {Variant}

Returns the formatted downstream value.

Implements:
Returns:

The formatted downstream value.

Type
Variant

getName() → {string}

Returns the renderer name.

This is set by the framework that instantiates the Renderer (e.g. the grid) and represents the field context (e.g. "Bid Price").

Implements:
Returns:

The renderer's name.

Type
string

getNamespace() → {string}

Returns the renderer namespace.

This is set by the framework that instantiates the Renderer (e.g. the grid) and represents the record context (e.g. "/FX/GBPUSD").

Implements:
Returns:

The renderer's namespace.

Type
string

getParsedValue() → {Variant}

Returns the parsed upstream value.

Implements:
Returns:

The parsed upstream value.

Type
Variant

getPrimaryFieldNames() → {Array.<string>}

Returns a list of primary fields.

Implements:
Returns:

The field names.

Type
Array.<string>

getSerialId() → {string}

Returns the serial id of the renderer instance.

Implements:
Returns:

The renderer serial id.

Type
string

getUnformattedValue() → {Variant}

Returns the unformatted downstream value.

Implements:
Returns:

The unformatted downstream value.

Type
Variant

getUnparsedValue() → {Variant}

Returns the unparsed upstream value.

Implements:
Returns:

The unparsed upstream value.

Type
Variant

getVariable(variableName) → {String}

Gets the renderer's variable.

Parameters:
Name Type Description
variableName String

The variable name to retrieve.

Returns:

The variable value

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

Implements:

isBound() → {boolean}

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

Implements:
See:
Returns:

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

Type
boolean

onRendererEvent(domEvent)

Event handler callback function that receives the events attached to the controls and defined in the handlers.

All control events call this function.

Parameters:
Name Type Description
domEvent object

The DOM event that was fired

raiseEvent(sType, mRendererEvent)

Raises a renderer event.

Parameters:
Name Type Description
sType string

The renderer event type.

mRendererEvent Map

The renderer event to raise.

Implements:

refresh()

Apply all pending updates

removeRendererEventListener(rendererEventListener)

Removes a module:ct-element/RendererEventListener to which the Renderer will communicate user-gestures.

Parameters:
Name Type Description
rendererEventListener module:ct-element/RendererEventListener

The renderer event listener.

Implements:

resetUnformattedStreamValue()

Creates a null value for this renderer type

select()

Moves the focus and highlights this renderer. Does nothing if the control has no concept of focus.

Implements:

setName(name)

Sets the renderer's name.

Parameters:
Name Type Description
name string

The renderer's name.

Implements:

setNamespace(namespace)

Sets the renderer's namespace.

Parameters:
Name Type Description
namespace string

The renderer's namespace.

Implements:

setSerialId(serialId)

Sets the serial id.

Parameters:
Name Type Description
serialId int

The serial id

unbind()

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

Implements:
See:

unbindHandlers()

Unbinds event listeners from the control for all the handlers.

updateFields(fieldValues)

Updates the renderer with the supplied fields. The field values will be reflected in the control on the next call to {module:ct-element/Renderer#refresh}.

The Renderer might depend on these fields either because it has been bound to them in the constructor, or if the XML renderer definition refers to these fields using the ${} notation.

Additional field values can be supplied and they will have no effect on the displayed value, but they will be returned by {module:ct-element/Renderer#getFieldValues}. This can exploited to hold additional information about the value (such as price ID or timestamp).

Parameters:
Name Type Description
fieldValues Map

the new field values.

Implements:

updateStreamValues(fieldValuesMap)

Updates the renderer with the new value.

Parameters:
Name Type Description
fieldValuesMap Map

The field values map.