Caplin Trader 5.1.0

Class: module:ct-grid/WebServiceGridDataProvider

module:ct-grid/WebServiceGridDataProvider()

new module:ct-grid/WebServiceGridDataProvider()

Constructs a new WebServiceGridDataProvider with the specified arguments.

This class can be used to supply a caplin grid's module:ct-grid/DataProviderRowModel with data retrieved from a web service.

An example web service can be found in the reference implementation (/source/services/historicalSnapshotJson.jsp) A grid web service should respond to queries with row data in a json format. An example is shown below.

{
  "dataSet": {
		  "fields" : ["Category","Date","Value","SubHeaderText"],
  "data" : [
		  ["","","","Short-term Bank Rates"],
		  ["EUR Repo","05/11/2008","3.75%",""],
		  ["EONIA","05/11/2008","3.75%",""]
	]
 }
}
Implements:

Methods

addDataProviderListener(listener)

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

Parameters:
Name Type Description
listener module:ct-grid/GridDataProviderListener

The listener to add.

Implements:
See:

clearFilterExpression(filterName)

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

Parameters:
Name Type Description
filterName string

The name of the filter.

Implements:

configureDataProvider(xmlConfigurationNode, isDataProviderDefinedByParent)

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

Parameters:
Name Type Description
xmlConfigurationNode Element

Access to the XML node that contains any configuration information the data provider needs to configure itself.

isDataProviderDefinedByParent boolean

Informs the data provider whether its configuration came via inheritance, or was configured locally — this will affect how the data provider should behave when its module:ct-grid/GridDataProvider#getSerializedState method is invoked.

Implements:

getAllFilterExpressions() → {map}

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

Implements:
Returns:

A map of module:ct-grid/filter/FilterExpression instances, if any exist, or an empty map otherwise.

Type
map

getDataForAllRows()

Returns an array of objects, each containing row record data

Returns:

an array of objects, each containing row record data

getDataSetFields() → {Array}

Returns the fields for which this data provider can provide data for.

Returns:

the fields for which this data provider can provide data for

Type
Array

getFilterExpression(filterName) → {module:ct-grid/filter/FilterExpression}

Returns a named filter expression.

Parameters:
Name Type Description
filterName String

The name of the filter to return — 'default' is the name given to filters generated from XML which lack the name attribute.

Implements:
Returns:

A FilterExpression, if one exists, or null otherwise.

Type
module:ct-grid/filter/FilterExpression

getGroupByField() → {string}

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

Implements:
Returns:

a String, if one exists, or null otherwise.

Type
string

getPermissionKey() → {module:ct-services/security/PermissionKey|null}

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.

Implements:
Returns:

a permissioning key, or null.

Type
module:ct-services/security/PermissionKey | null

getSerializedState() → {string}

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 module:ct-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 isDataProviderDefinedByParent passed within the module:ct-grid/GridDataProvider#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:

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

if this method is not implemented by the subclass.

Type
module:br/Errors.UnimplementedInterfaceError
Returns:

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.

Type
string

getSortRule() → {module:ct-grid/sort/SortRule}

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

Implements:
Returns:

a SortRule, if one exists, or null otherwise.

Type
module:ct-grid/sort/SortRule

pauseUpdates()

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

This method is invoked as a consequence of module:ct-grid/DataProviderRowModel#pauseUpdates being invoked. This method is a hint only, as the module:ct-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.

Implements:
See:

removeDataProviderListener(listener)

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

Parameters:
Name Type Description
listener module:ct-grid/GridDataProviderListener

The listener to remove.

Implements:
See:

resumeUpdates()

Signals the GridDataProvider to resume updates to all GridDataProviderListener instances.

Implements:
See:

setFilterExpression(filterExpression, filterName)

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:
Name Type Description
filterExpression module:ct-grid/filter/FilterExpression

A filter expression to apply to this data provider.

filterName string

The name of the filter.

Implements:

setRequiredFields(fieldNames)

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

Parameters:
Name Type Description
fieldNames Array.<string>

A list of field names.

Implements:

setRowRange(startIndex, size)

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.

Parameters:
Name Type Description
startIndex int

The start index of the first row within the range.

size int

The number of rows within the range.

Implements:
See:

supportsFeature(feature)

Determine whether this instance of GridDataProvider supports a particular feature.

Parameters:
Name Type Description
feature int

the feature constant that is being queried.

Implements:
See:

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.

Implements: