Class
caplin.grid

GridView

The class within the caplin.grid package that is responsible for displaying the rows specified within the provided caplin.grid.GridRowModel, and the columns specified within the provided caplin.grid.GridColumnModel. Additionally, GridView implements the caplin.component.Component interface so that it can be rendered within a web-based windowing framework (e.g. webcentric), and communicates with any specified caplin.grid.decorator.GridDecorator instances — these allow the grid functionality to be augmented in a modular way.

The GridView class is not designed to be constructed directly by user's of the CaplinTrader APIs. Instead, grid assemblies are defined using XML, and are constructed on demand using caplin.grid.GridComponentFactory.

Constructor Summary

Attributes Name and Description
caplin.grid.GridView(caplin.grid.GridDefinition gridDefinition, caplin.grid.GridRowModel gridRowModel, caplin.grid.GridColumnModel gridColumnModel, Array gridDecorators)

Constructs a new GridView with the specified arguments.

Method Summary

Attributes Name and Description
void addColumnHeaderRendererListener(caplin.element.RendererEventListener rendererEventListener)

Adds an caplin.element.RendererEventListener listener to the grid view.

void addGridViewListener(caplin.grid.GridViewListener gridViewListener)

Adds a listener to the grid view, to be communicated of all grid level events.

void addRendererEventListener(caplin.element.RendererEventListener rendererEventListener)

Adds a RendererEventListener to listen to any of the events that occur on renderers in the GridView.

void canReceive()

void canReceiveMultipleObjects()

void canReceiveObjects( receivedObjects)

HtmlElement getCellElement(int rowIndex, int columnIndex)

Returns the cell for the specified row and column.

caplin.element.Renderer getCellRenderer(int rowIndex, int columnIndex)

Returns the cell renderer responsible for rendering the given row and column indicies.

Map getElementIndicies(HtmlElement element)

Returns the map containing the row and column indices (rowIndex and columnIndex respectively) for the specified cell element.

caplin.grid.GridColumnModel getGridColumnModel()

Returns the underlying column model being used with the grid.

Array getGridDecorators()

Returns the decorators held by this Grid View

caplin.grid.GridRowModel getGridRowModel()

Returns the underlying row model being used with the grid.

caplin.grid.GridRowSelectionModel getGridRowSelectionModel()

Returns the row selection model being used with the grid.

HtmlElement getHeaderCellElement(int columnIndex)

Returns the header cell for the specified column.

caplin.element.Renderer getHeaderRenderer(int columnIndex)

Returns the header renderer responsible for rendering the given column index.

HtmlElement getHeaderRowElement()

Returns the header row.

void getLastReceiveFailureMessage()

int getNumberOfDisplayedRows()

Returns the number of rendered rows visible in the grid at the present point in time.

Array getRendererTypes()

Returns an array containing all Renderer Types for every column.

Map getRendererTypesIndexedByColumnName()

Returns a map containing all Renderer Types for every column, indexed by column friendly name.

HtmlElement getRowContainerElement()

Returns the grid row container element.

HtmlElement getRowElement(int rowIndex)

Returns the row element with the specified row index.

void getSuccessMessage()

int getTotalRowCount()

Returns the total number of rows in the dataset.

String getUniqueComponentId()

Gets a guaranteed ID for this component instance.

int getVisibleRowCount()

Returns the number of visible, populated rows in the grid.

boolean isColumnInView(int columnIndex)

Determines whether the specified column is in view.

boolean isRowInView(int rowIndex)

Determines whether the specified row is in view.

boolean isScrolling()

Test if the grid is currently being scrolled.

void isSortable()

The grid is sortable, unless it is empty.

void markAsDirty()

Calling this method will inform webcentric that the user's layout has changed.

void onAllDataReceived()

void onColumnsAdded( gridColumns, startIndex)

void onColumnsRemoved( gridColumns, startIndex)

void onFiltersChanged()

void onRendererEvent(caplin.element.Renderer renderer, Map rendererEvent, Map options)

The callback function to receive Renderer events.

void onRowContentsChanged( indices, rowUpdates)

void onRowDataUnavailable()

void onRowStructureChanged( indices)

void onScroll( nType, scrollAmount)

void onScrollComplete( nType, scrollAmount)

void onSizeChanged( newSize)

void onSortColumnChanged()

void onStartIndexChanged( newStartIndex)

void onWidthChanged( gridColumn)

void recalculateHeights()

Inform the grid that the styling applied to the grids has dynamically changed, affecting the current column header and/or rows heights.

void receiveObjects( receivedObjects)

void removeColumnHeaderRendererListener(caplin.element.RendererEventListener rendererEventListener)

Removes a listener previously been added via {#addColumnHeaderRendererListener}.

void removeGridViewListener(caplin.grid.GridViewListener gridViewListener)

Removes a previously registered grid view listener.

void setStartIndex(Number startIndex)

Set the first row being displayed within the grid.

Methods implemented from class caplin.component.Component:
getContainer, getElement, getPermissionKey, setContainer, setFrame
Methods from caplin.core.Serializable:
getSerializedState
Methods from caplin.component.ComponentLifecycleEvents:
onActivate, onClose, onDeactivate, onHide, onMaximize, onMinimize, onOpen, onResize, onRestore, onShow
Methods implemented from class caplin.grid.GridRowModelListener:
onRowDataReceived, onRowDataRequested, onRowModelStateChanged
Methods implemented from class caplin.grid.GridColumnModelListener:
onApplyFilters, onRequiredFieldsChanged

Constructor Detail

caplin.grid.GridView(caplin.grid.GridDefinition gridDefinition, caplin.grid.GridRowModel gridRowModel, caplin.grid.GridColumnModel gridColumnModel, Array gridDecorators)

Constructs a new GridView with the specified arguments.

This constructor should not be called directly, but instead caplin.grid.GridComponentFactory should be used for the construction of all grid assemblies.

Parameters
caplin.grid.GridDefinition gridDefinition The compiled XML definition of this grid.
caplin.grid.GridRowModel gridRowModel The row model to be displayed by this grid.
caplin.grid.GridColumnModel gridColumnModel The column model to be displayed by this grid.
Array gridDecorators The array of caplin.grid.decorator.GridDecorator instances to be applied to this grid.

Method Detail

void addColumnHeaderRendererListener(caplin.element.RendererEventListener rendererEventListener)

Adds an caplin.element.RendererEventListener listener to the grid view. Any events raised on any of the renderers on the GridView will raise an event. Use {#removeColumnHeaderRendererListener} to remove a listener.

Parameters
caplin.element.RendererEventListener rendererEventListener The listener to listener for renderer events.

void addGridViewListener(caplin.grid.GridViewListener gridViewListener)

Adds a listener to the grid view, to be communicated of all grid level events.

Parameters
caplin.grid.GridViewListener gridViewListener The grid view listener to add.

void addRendererEventListener(caplin.element.RendererEventListener rendererEventListener)

Adds a RendererEventListener to listen to any of the events that occur on renderers in the GridView.

Parameters
caplin.element.RendererEventListener rendererEventListener the listener to add.
See
caplin.element.RendererEventListener

void canReceive()

void canReceiveMultipleObjects()

void canReceiveObjects( receivedObjects)

Parameters
receivedObjects

HtmlElement getCellElement(int rowIndex, int columnIndex)

Returns the cell for the specified row and column.

Parameters
int rowIndex The row index of the cell
int columnIndex The column index of the cell
Returns
{HtmlElement} The DOM element the cell is being rendered within.

caplin.element.Renderer getCellRenderer(int rowIndex, int columnIndex)

Returns the cell renderer responsible for rendering the given row and column indicies.

Parameters
int rowIndex The index of the row for which the cell renderer will be returned.
int columnIndex The index of the column for which the cell renderer will be returned.
Returns
{caplin.element.Renderer} the cell renderer responsible for rendering the given row and column indicies

Map getElementIndicies(HtmlElement element)

Returns the map containing the row and column indices (rowIndex and columnIndex respectively) for the specified cell element. If the specified cell represents a header, only a columnIndex will be returned within the map.

Parameters
HtmlElement element The cell element for which the indices are required.
Returns
{Map} A map containing the rowIndex and columnIndex for the given element.

caplin.grid.GridColumnModel getGridColumnModel()

Returns the underlying column model being used with the grid.

Returns
{caplin.grid.GridColumnModel} The column model.

Array getGridDecorators()

Returns the decorators held by this Grid View

Returns
{Array} The decorators held by this Grid View

caplin.grid.GridRowModel getGridRowModel()

Returns the underlying row model being used with the grid.

Returns
{caplin.grid.GridRowModel} The row model.

caplin.grid.GridRowSelectionModel getGridRowSelectionModel()

Returns the row selection model being used with the grid.

Returns
{caplin.grid.GridRowSelectionModel} The row selection model.

HtmlElement getHeaderCellElement(int columnIndex)

Returns the header cell for the specified column.

Parameters
int columnIndex The column index of the cell
Returns
{HtmlElement} The DOM element the given header cell is rendered within.

caplin.element.Renderer getHeaderRenderer(int columnIndex)

Returns the header renderer responsible for rendering the given column index.

Parameters
int columnIndex The index of the column for which the header renderer will be returned.
Returns
{caplin.element.Renderer} the header renderer responsible for rendering the given column index

HtmlElement getHeaderRowElement()

Returns the header row.

Returns
{HtmlElement} The DOM element the header row is rendered within.

void getLastReceiveFailureMessage()

int getNumberOfDisplayedRows()

Returns the number of rendered rows visible in the grid at the present point in time.

Returns
{int} The number of currently displayed rows.

Array getRendererTypes()

Returns an array containing all Renderer Types for every column.

Returns
{Array} all renderer tpyes for every column

Map getRendererTypesIndexedByColumnName()

Returns a map containing all Renderer Types for every column, indexed by column friendly name.

Returns
{Map} all of the renderer types for every column.

HtmlElement getRowContainerElement()

Returns the grid row container element.

Returns
{HtmlElement} The DOM element the rows are being rendered within.

HtmlElement getRowElement(int rowIndex)

Returns the row element with the specified row index.

Parameters
int rowIndex The row index
Returns
{HtmlElement} The DOM element the given row is rendered within.

void getSuccessMessage()

int getTotalRowCount()

Returns the total number of rows in the dataset.

Returns
{int} The total number of rows.

String getUniqueComponentId()

Gets a guaranteed ID for this component instance.

Returns
{String} A unique ID

int getVisibleRowCount()

Returns the number of visible, populated rows in the grid.

Returns
{int} The number of visible rows.

boolean isColumnInView(int columnIndex)

Determines whether the specified column is in view.

Parameters
int columnIndex The column index corresponding to the column
Returns
{boolean} true if the column is in view, and false otherwise.

boolean isRowInView(int rowIndex)

Determines whether the specified row is in view.

Parameters
int rowIndex The row index corresponding to the row
Returns
{boolean} true if the row is in view, and false otherwise.

boolean isScrolling()

Test if the grid is currently being scrolled.

Returns
{boolean} true if the grid is currently being scrolled.

void isSortable()

The grid is sortable, unless it is empty.

void markAsDirty()

Calling this method will inform webcentric that the user's layout has changed. The layout will be marked using a *, informing the user that they must save their sheet to save any changes that have been made.

void onAllDataReceived()

void onColumnsAdded( gridColumns, startIndex)

Parameters
gridColumns
startIndex

void onColumnsRemoved( gridColumns, startIndex)

Parameters
gridColumns
startIndex

void onFiltersChanged()

void onRendererEvent(caplin.element.Renderer renderer, Map rendererEvent, Map options)

The callback function to receive Renderer events.

Parameters
caplin.element.Renderer renderer The renderer raising the event
Map rendererEvent The renderer event
Map options The event parameters
See
caplin.element.RendererEventListener#onRendererEvent

void onRowContentsChanged( indices, rowUpdates)

Parameters
indices
rowUpdates

void onRowDataUnavailable()

void onRowStructureChanged( indices)

Parameters
indices

void onScroll( nType, scrollAmount)

Parameters
nType
scrollAmount

void onScrollComplete( nType, scrollAmount)

Parameters
nType
scrollAmount

void onSizeChanged( newSize)

Parameters
newSize

void onSortColumnChanged()

void onStartIndexChanged( newStartIndex)

Parameters
newStartIndex

void onWidthChanged( gridColumn)

Parameters
gridColumn

void recalculateHeights()

Inform the grid that the styling applied to the grids has dynamically changed, affecting the current column header and/or rows heights.

Some uses of the grid may involve changing the display mode at runtime, so that the column headers or the rows themselves have a different height in these different modes. Although a display mode switch may be affected by the developer by setting a class name on the root grid element, and having different CSS rules for each mode, the grid must also be informed about this so that it's rendering logic can continue to work.

void receiveObjects( receivedObjects)

Parameters
receivedObjects

void removeColumnHeaderRendererListener(caplin.element.RendererEventListener rendererEventListener)

Removes a listener previously been added via {#addColumnHeaderRendererListener}.

Parameters
caplin.element.RendererEventListener rendererEventListener The listener to remove.

void removeGridViewListener(caplin.grid.GridViewListener gridViewListener)

Removes a previously registered grid view listener.

Parameters
caplin.grid.GridViewListener gridViewListener The grid view listener to remove.

void setStartIndex(Number startIndex)

Set the first row being displayed within the grid.

Parameters
Number startIndex The row that will be displayed at the top of the grid.