© 2014, Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and or/its affiliates and/or their licensors.
Generated by JsDoc Toolkit 2.3.2

Class Presto .DataTable

Creates a new DataTable instance. DataTables extends the Presto.Observable class. They are observable client data models with a flat, tabular structure, that enables client access and control for mashable or mashup responses.

This constructor uses a single configuration object to populate the DataTable. The properties in the configuration object determine how data for the DataTable is obtained and managed:

  • Populate explicitly with all passed response data: the data is passed explicitly in a configuration property. The DataTable attempts to automatically find a repeating element by analyzing the data and using that to flatten the data into a table model. In this mode, the first repeating element found in the data is used as the record definition for the DataTable.

  • Request data from Presto and populate with all response data: Configuration information defines a request to send to a Presto service or mashup to obtain data. The Mashup Server returns the full data set in the response.

    The repeating element to use as records for the DataTable can be discovered automatically (first repeating element found is used) or configuration can define a specific repeating element as the "record" to use to populate the DataTable.

  • Request data from a Presto mashable or mashup and allow the server to paginate response data: Configuration information defines a request to send to Presto to obtain data. It also defines the specific repeating element to use as the "record" for pagination and other pagination properties. The Mashup Server caches the response and returns the requested pagination set. Subsequent requests can obtain additional pagination sets or reload the cache with a new request.

Class Summary
Constructor AttributesConstructor Name and Description
 
Field Summary
Field AttributesField Name and Description
 

An array of column objects for this DataTable.

 

An array of complex column objects for this DataTable.

 

The absolute XPath expression that defines the repeating nodes that represent records for this DataTable.

 

An array of objects containing the data for the records in this DataTable.

 

Indicates whether a path has been defined or calculated for the repeating nodes to populate this DataTable.

Method Summary
Method AttributesMethod Name and Description
 
getColumn(colName)

Returns the column object for the specified column.

 

Returns an array with all column names for this DataTable.

 

Returns an array of column objects for this DataTable.

 

Returns the complex column object for the specified complex column.

 

Returns an array with all complex column names for this DataTable.

 

Returns an array of complex column objects for this DataTable.

 

Returns the value of the last used pagination count, the number of rows returned in a pagination set (options.pageSize).

 

Returns the value of the last used pagination cursor (options.cursor).

 
getRange(start, end)

Returns an array of objects for the specified rows for this DataTable.

 

Returns the raw data, in JSON format, for this DataTable.

 
getRequestParams(callback)

Return an array of simple (non-complex) request parameters for the configured dataTable service operation request.

 

Returns the total number of rows in the DataTable.

 
getRowData(rowIndex)

Returns the row object for the specified row index.

 

Returns an array of row objects for all rows in this DataTable.

 

Returns the total number of rows in cache in the Mashup Server for this DataTable.

 
getValue(rowIndex, columnName)

Returns the value for the specified row and column name in this DataTable.

 

Returns true if data has been populated in this DataTable.

 
load(params, options, callback)

Sends the specified request to Presto and uses the response to populate the DataTable.

 
loadData(jsonData)

Loads the specified data in the DataTable.

 
page(pagingOptions, callback)

Loads a pagination set for this DataTable based on the paging options specified.

 
rowClick(rowIndex)

Can be called by a view when a user clicks on the visual representation of a given row, such as a table row, a column or pie slice in a chart or a marker on a map.

 
selectRow(rowIndex, select)

Forcibly sets the selected state of a given DataTable row to the given state.

Class Detail
Presto.DataTable(config)
Parameters:
{Object} config
The configuration object to populate this DataTable. This object must contain either a jsonData property or a request and connection property.
{Object} config.jsonData
The data, in JSON format, to populate this DataTable. If this property is used, all other configuration properties are ignored.
{Object} config.request
An object with configuration for a Presto Connect request to invoke a mashable or mashup. The request object is in the form { url: service-REST-url, [contentType: http-content-type], method: get-or-post, [data: request-body]}. You can also specify optional parameters in the data property. For more information, see the Presto Connect request method.
{Object} config.connection
A Presto.Connection object to the Mashup Server for this request. This must define the URL to the Mashup Server and optionally, user credentials. For more information see Presto.Connection.
{String} config.record
An XPath expression that identifies the specific repeating items to use to populate this DataTable. If response data contains namespaces, this XPath expression must also specify the namespace. This property is only required when server-side pagination is used (see remotePaging
{Boolean} config.remotePaging
A true | false flag indicating whether pagination is handled by the server (true) or not. If true, both the record and pageLimit properties must also be defined.
{Number} config.pageLimit
The maximum number of records to return in any given paginated response when server-side pagination is requested.
Field Detail
cols

An array of column objects for this DataTable. Column objects have a name and a path property.

complexCols

An array of complex column objects for this DataTable. Column objects have a name and a path property and children as simple columns.

record

The absolute XPath expression that defines the repeating nodes that represent records for this DataTable.

rows

An array of objects containing the data for the records in this DataTable. Each object represents one row or record with properties for each column.

selectedRecord

Indicates whether a path has been defined or calculated for the repeating nodes to populate this DataTable. If the record property is not set and no repeating nodes were found, this is null.

If set, this is an object of the form: {
name: name-of-the-node
leaves: array of leaf nodes, each node being of the form {name, path, pathWithoutNS}
path: full path to this selected record with namespace
pathWithoutNS: path to the selected record without namespace
childElements: array of child nodes, each being of the form {name, path, pathWithoutNS}
}

Method Detail
getColumn(colName)

Returns the column object for the specified column.

Parameters:
{String} colName
The name of the column.
getColumnNames()

Returns an array with all column names for this DataTable.

getColumns()

Returns an array of column objects for this DataTable. Returns null if the DataTable has not been populated.

getComplexColumn(colName)

Returns the complex column object for the specified complex column.

Parameters:
{String} colName
The name of the column.
getComplexColumnNames()

Returns an array with all complex column names for this DataTable.

getComplexColumns()

Returns an array of complex column objects for this DataTable. Returns null if the DataTable has not been populated.

getCount()

Returns the value of the last used pagination count, the number of rows returned in a pagination set (options.pageSize). This is also the desired pageSize provided by the user in page method.

To get the current row count, use getRowCount. To get the total number of of rows cached in the Mashup Server, use getTotalCount.

getCursor()

Returns the value of the last used pagination cursor (options.cursor). This is either the start row number for a successful paginated request or -1 if the request failed.

getRange(start, end)

Returns an array of objects for the specified rows for this DataTable. You may omit either or both parameters. Or use an end row of -1 to return all rows. If the DataTable has not be populated, this returns an empty array.

Parameters:
{Number} start
Optional index number of the first row to return. Defaults to 0 (first row) if omitted.
{Number} end
Optional index number of the last row to return. Defaults to -1 (return all rows) if omitted.
getRawData()

Returns the raw data, in JSON format, for this DataTable.

getRequestParams(callback)

Return an array of simple (non-complex) request parameters for the configured dataTable service operation request.

The parameter details can be used to compose a parameter object, with primitive values, which can be used when invoking the dataTable.load method.

The dataTable.request object must be configured with a valid serviceUri or sid and oid values.

The parameter array is returned via a callback function.

Parameters:
{Function} callback
function to return array of parameter details.
getRowCount()

Returns the total number of rows in the DataTable. Returns zero if the DataTable has not been populated.

getRowData(rowIndex)

Returns the row object for the specified row index. Returns null if the DataTable has not been populated. Throws an exception if the specified row does not exist.

Parameters:
{Number} rowIndex
The index number of the row.
getRows()

Returns an array of row objects for all rows in this DataTable. Returns null if the DataTable has not been populated.

getTotalCount()

Returns the total number of rows in cache in the Mashup Server for this DataTable. If the response is not paginated, returns -1.

getValue(rowIndex, columnName)

Returns the value for the specified row and column name in this DataTable. Returns null if the DataTable has not been populated. Throws an exception if the specified row or column does not exist.

Parameters:
{Number} rowIndex
The index number of the row.
{String} columnName
The name of the column.
isDataAvailable()

Returns true if data has been populated in this DataTable.

load(params, options, callback)

Sends the specified request to Presto and uses the response to populate the DataTable. Use this function to invoke a Presto mashable or mashup, and optionally request server-side pagination for the response.

This function also fires the load or loaderror event, calling the appropriate DataTable listeners. The load event contains all rows used to populate the DataTable. The loaderror event contains an error message.

Parameters:
params
An array or an object with parameters to send with this request to load data in this DataTable.
{Object} options
An optional configuration object to override existing pagination properties:
{Number} options.start
The index number of the first record to return in this pagination set.
{Number} options.pageLimit
The maximum number of records to return in this pagination set.
{Boolean} options.reload
An optional flag that determines whether this call reloads the pagination cache (true) by sending the request to Presto or simply requests a different pagination set (false). This is false by default.
{Object} callback
The callbacks to use with this request. This is in the form: { onSuccess: function(scope, rowRange), onFailure: function (scope, error) }.
loadData(jsonData)

Loads the specified data in the DataTable. Use this function when the data for the DataTable does not require a request to Presto or pagination from the Mashup Server. This function also fires the load event, calling the appropriate DataTable listeners.

Parameters:
{Object} jsonData
The data, in JSON format, to load in the DataTable.
page(pagingOptions, callback)

Loads a pagination set for this DataTable based on the paging options specified. This can also force the Mashup Server to reinvoke the mashable or mashup and reload the entire DataTable.

Parameters:
{Object} pagingOptions
An object with properties defining the specific pagination set the server should return for this DataTable.
{Number} pagingOptions.start
The index number of the first record to return in this pagination set.
{Number} pagingOptions.pageLimit
The maximum number of records to return in this pagination set.
{Boolean} pagingOptions.reload
An optional flag that determines whether this call reloads the pagination cache (true) by sending the request to Presto or simply requests a different pagination set (false). This is false by default.
{Object} callback
The callbacks to use with this request. This is in the form: { onSuccess: function(scope, rowRange), onFailure: function (scope, error) }
rowClick(rowIndex)

Can be called by a view when a user clicks on the visual representation of a given row, such as a table row, a column or pie slice in a chart or a marker on a map. DataTable toggles the selected state of the specified row, along with the state of the previously selected row if different, and fires a rowselect event to notify any other views using this DataTable.

Parameters:
{String or Number} rowIndex
The index number for the row that the user clicked.
selectRow(rowIndex, select)

Forcibly sets the selected state of a given DataTable row to the given state.

Parameters:
{Number} rowIndex
The index number of the row whose selected state must be changed.
{Boolen} select
Whether the state of the row should be forced to be selected or not.