Interface
caplin.grid

GridDataProvider

GridDataProvider classes allow data from different data sources to be displayed within a grid when used in conjunction with an instance of caplin.grid.DataProviderRowModel. The GridDataProvider interface is much simpler to implement than the full caplin.grid.GridRowModel interface, and should allow most, if not all, grid row models to be developed, and so is the preferred way of creating a caplin.grid.GridRowModel.

Although Caplin will provide a set of generic data providers for retrieving different data types from a Liberator (e.g. caplin.grid.RttpContainerGridDataProvider for retrieving RTTP container data), it is also anticipated that customers may also need to create their own data provider classes for accessing other forms of data, e.g. a data provider that accesses a custom web-service. So, GridDataProvider is the interface that customers wishing to have custom data displayed within a grid must implement.

Constructor Summary

Attributes Name and Description
caplin.grid.GridDataProvider()

Field Summary

Attributes Name and Description
<static> caplin.grid.GridDataProvider.FILTERING

A constant definition used with #supportsFeature to allow data providers to declare whether they support filtering.

<static> caplin.grid.GridDataProvider.PAGING

A constant definition used with #supportsFeature to allow data providers to declare whether they support paging.

<static> caplin.grid.GridDataProvider.SORTING

A constant definition used with #supportsFeature to allow data providers to declare whether they support sorting.

Method Summary

Attributes Name and Description
void addDataProviderListener(caplin.grid.GridDataProviderListener oDataProviderListener)

Adds a listener to the data provider, to be communicated of all data provider events.

void clearFilterExpression(String sFilterName)

Remove a named filter expression.

void clearGroupByField()

Removes any grouping from the grid row model.

void clearSortRule()

Removes any sorting from the grid row model.

void configureDataProvider(Element eXmlConfigurationNode, boolean bDataProviderDefinedByParent)

Allow the data provider to configure itself based on the XML attributes from the node used to configure the data provider.

Map getAllFilterExpressions()

A map of all the filter expressions added to this data provider.

caplin.grid.filter.FilterExpression getFilterExpression(String sFilterName)

Returns a named filter expression.

void getGroupByField()

Get the field, if one has been set, that is used to group the rows contained within row model.

caplin.services.security.PermissionKey|null getPermissionKey()

Returns a permissioning key tuple that can be used to query the permissioning system to determine whether the user is permitted to access the data that this data provider will be providing.

String getSerializedState()

Invoked when the grid row model needs to save the state of this data provider.

void getSortRule()

Get the rule, if one exists, that is used to sort the data within the row model.

void getStartIndex()

Returns the start index that is set on the Data Provider via the #setRowRange method.

void getSubjectIdentifiers(caplin.grid.GridDataProviderSnapshotListener oSnapshotListener)

Returns the array of subject identifiers provided by the data provider.

String getTransformMode()

Get the transform mode that determines how grid updates are pushed out from the data source.

void injectData(String sSubject, Map mData)

Injects a map of Data consistent on field_name:value pairs into a record given by its subject.

void pauseUpdates()

Signals the GridDataProvider to temporarily pause updates to any GridDataProviderListener instances.

void removeDataProviderListener(caplin.grid.GridDataProviderListener oDataProviderListener)

Removes a GridDataProviderListener that no longer wishes to listen to data updates.

void requestAllData()

Inform the GridDataProvider that it is now permitted to begin sending data.

void resumeUpdates()

Signals the GridDataProvider to resume updates to all GridDataProviderListener instances.

void setFilterExpression(caplin.grid.filter.FilterExpression oFilterExpression, String sFilterName)

Set a filter expression on this data provider.

void setFilters(Array pActiveColumnFilters, mAllColumns)

Informs the GridDataProvider of the currently active column filters.

void setGridView(caplin.grid.GridView oGridView)

The opportunity for the data provider to add itself as a listener to the the caplin.grid.GridView as a renderer event listener.

void setGroupByField(String sFieldName)

Sets the field to be used for grouping the rows within the row model.

void setRequiredFields(Array pFieldNames)

Sets the required fields that this data provider should provide within each record.

void setRowData( sSubject, mRowData)

Updates the data on editable row.

void setRowRange(int nStartIndex, int nSize)

Sets the start index and total number of rows that this GridDataProvider should supply when notifying listeners of row updates — this will change as the view is scrolled or resized to reveal different rows.

void setSortRule(caplin.grid.sort.SortRule oSortRule)

Set a rule that will be used to sort the data within the row model.

void setTransformMode(String sTransformMode)

Sets the update mode that determines how grid updates are pushed out from the data source.

void supportsFeature(int nFeature)

Determine whether this instance of GridDataProvider supports a particular feature.

void terminateUpdates()

Signals the GridDataProvider to permanently terminate updates to any GridDataProviderListener instances.

Methods implemented from class caplin.component.InstrumentReceiver:
canReceive, canReceiveMultipleObjects, canReceiveObjects, getLastReceiveFailureMessage, getSuccessMessage, receiveObjects

Constructor Detail

caplin.grid.GridDataProvider()

Field Detail

<static> caplin.grid.GridDataProvider.FILTERING

A constant definition used with #supportsFeature to allow data providers to declare whether they support filtering.

Data providers that do support filtering will need to correctly implement #setFilters.

<static> caplin.grid.GridDataProvider.PAGING

A constant definition used with #supportsFeature to allow data providers to declare whether they support paging.

Data providers that do support paging will need to implement #setRowRange, whereas data providers that do not implement paging will instead need to implement #requestAllData.

<static> caplin.grid.GridDataProvider.SORTING

A constant definition used with #supportsFeature to allow data providers to declare whether they support sorting.

Data providers that do support sorting will need to correctly implement #sortBy.

Method Detail

void addDataProviderListener(caplin.grid.GridDataProviderListener oDataProviderListener)

Adds a listener to the data provider, to be communicated of all data provider events.

Parameters
caplin.grid.GridDataProviderListener oDataProviderListener The listener to add.
See
#removeDataProviderListener

void clearFilterExpression(String sFilterName)

Remove a named filter expression. Once removed the data provider will reset itself to display the data without the removed filter.

Parameters
String sFilterName The name of the filter.

void clearGroupByField()

Removes any grouping from the grid row model.

void clearSortRule()

Removes any sorting from the grid row model.

void configureDataProvider(Element eXmlConfigurationNode, boolean bDataProviderDefinedByParent)

Allow the data provider to configure itself based on the XML attributes from the node used to configure the data provider.

Parameters
Element eXmlConfigurationNode Access to the XML node that contains any configuration information the data provider needs to configure itself.
boolean bDataProviderDefinedByParent Informs the data provider whether its configuration came via inheritance, or was configured locally — this will affect how the data provider should behave when it's #getSerializedState method is invoked.

Map getAllFilterExpressions()

A map of all the filter expressions added to this data provider.

Returns
{Map} A map of caplin.grid.filter.FilterExpression instances, if any exist, or an empty map otherwise.

caplin.grid.filter.FilterExpression getFilterExpression(String sFilterName)

Returns a named filter expression.

Parameters
String sFilterName The name of the filter to return — 'default' is the name given to filters generated from XML which lack the name attribute.
Returns
{caplin.grid.filter.FilterExpression} A caplin.grid.filter.FilterExpression, if one exists, or null otherwise.

void getGroupByField()

Get the field, if one has been set, that is used to group the rows contained within row model.

Returns
a String, if one exists, or null otherwise.

caplin.services.security.PermissionKey|null getPermissionKey()

Returns a permissioning key tuple that can be used to query the permissioning system to determine whether the user is permitted to access the data that this data provider will be providing.

Data providers whose data is not permissioned need not return a permissioning key.

Returns
{caplin.services.security.PermissionKey|null} a permissioning key, or null.

String getSerializedState()

Invoked when the grid row model needs to save the state of this data provider. It returns an XML string representation of the state.

This interface differs from the implemented caplin.core.Serializable interface in the following way.

If the state of the data provider has changed since deserialization, or the data provider state has ever changed in the past (i.e. the bDataProviderDefinedByParent passed within the #configureDataProvider method was false, then the data provider should return a serialized representation of itself. If this is not the case, however, the data provider should otherwise return null.

Example:

caplin.grid.RttpContainerGridDataProvider.prototype.getSerializedState = function() {
    if (this.m_bStateChanged || !this.m_bDataProviderDefinedByParent) {
        var sEncodedContainerName = caplin.core.XmlUtility.encodeValue(this.m_sOriginalContainerName);
        return '		\n';
    }
    return null;
};

Throws
caplin.core.Error
if this method is not implemented by the subclass.
Returns
{String} An XML string representation of the state of this component, or null if there have not been any changes to the data provider. Must not be undefined.

void getSortRule()

Get the rule, if one exists, that is used to sort the data within the row model.

Returns
a caplin.grid.sort.SortRule, if one exists, or null otherwise.

void getStartIndex()

Returns the start index that is set on the Data Provider via the #setRowRange method.

Returns
A number representing the start index the data provider has been set at, or null if not yet set.

void getSubjectIdentifiers(caplin.grid.GridDataProviderSnapshotListener oSnapshotListener)

Returns the array of subject identifiers provided by the data provider.

This will include all subject identifiers, not just those within the current view.

Parameters
caplin.grid.GridDataProviderSnapshotListener oSnapshotListener

String getTransformMode()

Get the transform mode that determines how grid updates are pushed out from the data source.

Returns
{String} The transform mode - either 'snapshot' or 'live'

void injectData(String sSubject, Map mData)

Injects a map of Data consistent on field_name:value pairs into a record given by its subject.

The GridDataProvider will notify all its observables about a record change with this data

Parameters
String sSubject
Map mData

void pauseUpdates()

Signals the GridDataProvider to temporarily pause updates to any GridDataProviderListener instances.

This method is invoked as a consequence of caplin.grid.DataProviderRowModel#pauseUpdates being invoked. This method is a hint only, as the caplin.grid.DataProviderRowModel will also perform caching of updates so they do not need to be rendered to the screen. By implementing pausing at the data provider level, however, additional processor usage can be conserved allowing multiple sheets to be opened without increasing the burden placed on they processor.

See
#resumeUpdates
caplin.grid.DataProviderRowModel#pauseUpdates

void removeDataProviderListener(caplin.grid.GridDataProviderListener oDataProviderListener)

Removes a GridDataProviderListener that no longer wishes to listen to data updates.

Parameters
caplin.grid.GridDataProviderListener oDataProviderListener The listener to remove.
See
#addDataProviderListener

void requestAllData()

Inform the GridDataProvider that it is now permitted to begin sending data.

requestAllData is only invoked on classes that do not support PAGING. Classes that do support paging will receive multiple invocations to #setRowRange instead.

See
#setRowRange
#supportsFeature

void resumeUpdates()

Signals the GridDataProvider to resume updates to all GridDataProviderListener instances.

See
#pauseUpdates
caplin.grid.DataProviderRowModel#resumeUpdates

void setFilterExpression(caplin.grid.filter.FilterExpression oFilterExpression, String sFilterName)

Set a filter expression on this data provider. This will filter the grid data according to the operator and values of the filter expression.

Parameters
caplin.grid.filter.FilterExpression oFilterExpression A filter expression to apply to this data provider.
String sFilterName The name of the filter.

void setFilters(Array pActiveColumnFilters, mAllColumns)

Informs the GridDataProvider of the currently active column filters.

Parameters
Array pActiveColumnFilters An array of all the currently active caplin.grid.GridColumnFilter instances.
mAllColumns A map of all GridView's column caplin.grid.GridColumn instances.

void setGridView(caplin.grid.GridView oGridView)

The opportunity for the data provider to add itself as a listener to the the caplin.grid.GridView as a renderer event listener.

Parameters
caplin.grid.GridView oGridView The view that the data provider/controller can use to communicate with the View/Model.

void setGroupByField(String sFieldName)

Sets the field to be used for grouping the rows within the row model.

Parameters
String sFieldName The field name that will be used for grouping.

void setRequiredFields(Array pFieldNames)

Sets the required fields that this data provider should provide within each record.

Parameters
Array pFieldNames A list of field names as strings.

void setRowData( sSubject, mRowData)

Updates the data on editable row. Currently the data received is updated in a local cache and merged with received data works only if supported by implementing class (bEditable is set to true)

Parameters
sSubject - subject(objectName) of the row to be updated
mRowData - map with field name and values to be updated for the subject specified

void setRowRange(int nStartIndex, int nSize)

Sets the start index and total number of rows that this GridDataProvider should supply when notifying listeners of row updates — this will change as the view is scrolled or resized to reveal different rows.

setRowRange is only invoked on classes that support #PAGING. Classes that do not support paging will receive a single invocation to #requestAllData instead.

Parameters
int nStartIndex The start index of the first row within the range.
int nSize The number of rows within the range.
See
#requestAllData
#supportsFeature

void setSortRule(caplin.grid.sort.SortRule oSortRule)

Set a rule that will be used to sort the data within the row model.

Parameters
caplin.grid.sort.SortRule oSortRule The object containing the sort parameters.

void setTransformMode(String sTransformMode)

Sets the update mode that determines how grid updates are pushed out from the data source.

Parameters
String sTransformMode The update mode to use.

void supportsFeature(int nFeature)

Determine whether this instance of GridDataProvider supports a particular feature.

Parameters
int nFeature the feature constant that is being queried.
See
#PAGING
#SORTING
#FILTERING

void terminateUpdates()

Signals the GridDataProvider to permanently terminate updates to any GridDataProviderListener instances.

This method is essentially the destructor for classes implementing GridDataProvider, and is the opportunity to perform any clean-up that may be required.