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 oGridDefinition, caplin.grid.GridRowModel oGridRowModel, caplin.grid.GridColumnModel oGridColumnModel, Array pGridDecorators)

Constructs a new GridView with the specified arguments.

Method Summary

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

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

void addGridViewListener(caplin.grid.GridViewListener oGridViewListener)

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

void addRendererEventListener(caplin.element.RendererEventListener oRendererEventListener)

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

DOMElement getCellElement(int nRowIndex, int nColumnIndex)

Returns the cell for the specified row and column.

caplin.element.Renderer getCellRenderer(int nRowIndex, int nColumnIndex)

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

Map getElementIndicies(HtmlElement eElement)

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 nColumnIndex)

Returns the header cell for the specified column.

caplin.element.Renderer getHeaderRenderer(int nColumnIndex)

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

HtmlElement getHeaderRowElement()

Returns the header row.

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 nRowIndex)

Returns the row element with the specified row index.

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 nColumnIndex)

Determines whether the specified column is in view.

boolean isRowInView(int nRowIndex)

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 onRendererEvent(caplin.element.Renderer oRenderer, Map mRendererEvent, Map mParameters)

The callback function to receive Renderer events.

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 removeColumnHeaderRendererListener(caplin.element.RendererEventListener oRendererEventListener)

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

void removeGridViewListener(caplin.grid.GridViewListener oGridViewListener)

Removes a previously registered grid view listener.

void setStartIndex(Number nStartIndex)

Set the first row being displayed within the grid.

Methods implemented from class caplin.component.Component:
getContainer, getElement, getPermissionKey, getSerializedState, setContainer, setFrame
Methods from caplin.component.ComponentLifecycleEvents:
onActivate, onClose, onDeactivate, onHide, onMaximize, onMinimize, onOpen, onResize, onRestore, onShow
Methods implemented from class caplin.grid.GridRowModelListener:
onAllDataReceived, onRowContentsChanged, onRowDataReceived, onRowDataRequested, onRowDataUnavailable, onRowModelStateChanged, onRowStructureChanged, onSizeChanged, onStartIndexChanged
Methods implemented from class caplin.grid.GridColumnModelListener:
onApplyFilters, onColumnsAdded, onColumnsRemoved, onFiltersChanged, onRequiredFieldsChanged, onSortColumnChanged, onWidthChanged

Constructor Detail

caplin.grid.GridView(caplin.grid.GridDefinition oGridDefinition, caplin.grid.GridRowModel oGridRowModel, caplin.grid.GridColumnModel oGridColumnModel, Array pGridDecorators)

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 oGridDefinition The compiled XML definition of this grid.
caplin.grid.GridRowModel oGridRowModel The row model to be displayed by this grid.
caplin.grid.GridColumnModel oGridColumnModel The column model to be displayed by this grid.
Array pGridDecorators The array of caplin.grid.decorator.GridDecorator instances to be applied to this grid.

Method Detail

void addColumnHeaderRendererListener(caplin.element.RendererEventListener oRendererEventListener)

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 oRendererEventListener The listener to listener for renderer events.

void addGridViewListener(caplin.grid.GridViewListener oGridViewListener)

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

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

void addRendererEventListener(caplin.element.RendererEventListener oRendererEventListener)

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

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

DOMElement getCellElement(int nRowIndex, int nColumnIndex)

Returns the cell for the specified row and column.

Parameters
int nRowIndex The row index of the cell
int nColumnIndex The column index of the cell
Returns
The DOM element the cell is being rendered within.

caplin.element.Renderer getCellRenderer(int nRowIndex, int nColumnIndex)

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

Parameters
int nRowIndex The index of the row for which the cell renderer will be returned.
int nColumnIndex The index of the column for which the cell renderer will be returned.
Returns
the cell renderer responsible for rendering the given row and column indicies

Map getElementIndicies(HtmlElement eElement)

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 eElement The cell element for which the indices are required.
Returns
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
The column model.

Array getGridDecorators()

Returns the decorators held by this Grid View

Returns
The decorators held by this Grid View

caplin.grid.GridRowModel getGridRowModel()

Returns the underlying row model being used with the grid.

Returns
The row model.

caplin.grid.GridRowSelectionModel getGridRowSelectionModel()

Returns the row selection model being used with the grid.

Returns
The row selection model.

HtmlElement getHeaderCellElement(int nColumnIndex)

Returns the header cell for the specified column.

Parameters
int nColumnIndex The column index of the cell
Returns
The DOM element the given header cell is rendered within.

caplin.element.Renderer getHeaderRenderer(int nColumnIndex)

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

Parameters
int nColumnIndex The index of the column for which the header renderer will be returned.
Returns
the header renderer responsible for rendering the given column index

HtmlElement getHeaderRowElement()

Returns the header row.

Returns
The DOM element the header row is rendered within.

int getNumberOfDisplayedRows()

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

Returns
The number of currently displayed rows.

Array getRendererTypes()

Returns an array containing all Renderer Types for every column.

Returns
all renderer tpyes for every column

Map getRendererTypesIndexedByColumnName()

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

Returns
all of the renderer types for every column.

HtmlElement getRowContainerElement()

Returns the grid row container element.

Returns
The DOM element the rows are being rendered within.

HtmlElement getRowElement(int nRowIndex)

Returns the row element with the specified row index.

Parameters
int nRowIndex The row index
Returns
The DOM element the given row is rendered within.

int getTotalRowCount()

Returns the total number of rows in the dataset.

Returns
The total number of rows.

String getUniqueComponentId()

Gets a guaranteed ID for this component instance.

Returns
A unique ID

int getVisibleRowCount()

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

Returns
The number of visible rows.

boolean isColumnInView(int nColumnIndex)

Determines whether the specified column is in view.

Parameters
int nColumnIndex The column index corresponding to the column
Returns
true if the column is in view, and false otherwise.

boolean isRowInView(int nRowIndex)

Determines whether the specified row is in view.

Parameters
int nRowIndex The row index corresponding to the row
Returns
true if the row is in view, and false otherwise.

boolean isScrolling()

Test if the grid is currently being scrolled.

Returns
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 onRendererEvent(caplin.element.Renderer oRenderer, Map mRendererEvent, Map mParameters)

The callback function to receive Renderer events.

Parameters
caplin.element.Renderer oRenderer The renderer raising the event
Map mRendererEvent The renderer event
Map mParameters The event parameters
See
caplin.element.RendererEventListener

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 removeColumnHeaderRendererListener(caplin.element.RendererEventListener oRendererEventListener)

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

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

void removeGridViewListener(caplin.grid.GridViewListener oGridViewListener)

Removes a previously registered grid view listener.

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

void setStartIndex(Number nStartIndex)

Set the first row being displayed within the grid.

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