/**
* Copyright (c) 2014, Oracle and/or its affiliates.
* All rights reserved.
*/
/**
* A CellSet represents a collection of cells. The CellSet is an object returned by the success callback
* of the fetchCells method on DataGridDataSource. This implementation of CellSet is used by the
* array DataGridDataSource.
* @param {number} startRow the start row index of the cell set
* @param {number} endRow the end row index of the cell set
* @param {number} startColumn the start column index of the cell set
* @param {number} endColumn the end column index of the cell set
* @param {Object} callback the callback to invoke on to retrieve data and metadata.
* @constructor
* @export
*/
oj.ArrayCellSet = function(startRow, endRow, startColumn, endColumn, callback)
{
// assert startRow/startColumn are number
oj.Assert.assertNumber(startRow, null);
oj.Assert.assertNumber(endRow, null);
oj.Assert.assertNumber(startColumn, null);
oj.Assert.assertNumber(endColumn, null);
this.m_startRow = startRow;
this.m_endRow = endRow;
this.m_startColumn = startColumn;
this.m_endColumn = endColumn;
this.m_callback = callback;
};
/**
* Gets the data of the specified index. An error is throw when 1) the range is not yet available
* 2) the index specified is out of bounds.
* @param {Object} indexes the index of each axis in which we want to retrieve the data from.
* @param {number} indexes.row the index of the row axis.
* @param {number} indexes.column the index of the column axis.
* @return {Object} the data object for the specified index.
* @export
*/
oj.ArrayCellSet.prototype.getData = function(indexes)
{
return this.m_callback._getCellData(indexes['row'], indexes['column']);
};
/**
* Gets the metadata of the specified index. An error is throw when 1) the range is not yet available
* 2) the index specified is out of bounds.
* @param {Object} indexes the index of each axis in which we want to retrieve the metadata from.
* @param {number} indexes.row the index of the row axis.
* @param {number} indexes.column the index of the column axis.
* @return {Object} the metadata object for the specific index. The metadata that the DataGrid supports are:
* 1) keys - the key (of each axis) of the cell.
* @export
*/
oj.ArrayCellSet.prototype.getMetadata = function(indexes)
{
return this.m_callback._getCellMetadata(indexes['row'], indexes['column']);
};
/**
* Gets the start index of the result set for the specified axis. Valid values are "row" and "column".
* @param {string} axis the axis in which to inquire the actual count of the result set.
* @return {number} the start index of the result set for the specified axis.
* @export
*/
oj.ArrayCellSet.prototype.getStart = function(axis)
{
if (axis == "row")
{
return this.m_startRow;
}
else if (axis == "column")
{
return this.m_startColumn;
}
return -1;
};
/**
* Gets the actual count of the result set for the specified axis. Valid values are "row" and "column".
* @param {string} axis the axis in which to inquire the actual count of the result set.
* @return {number} the actual count of the result set for the specified axis.
* @export
*/
oj.ArrayCellSet.prototype.getCount = function(axis)
{
if (axis === "row")
{
return Math.max(0, this.m_endRow - this.m_startRow);
}
if (axis === "column")
{
return Math.max(0, this.m_endColumn - this.m_startColumn);
}
return 0;
};
////// testing methods to get properties //////
/**
* Gets the start row property for testing
* @return {number} the start row
* @export
* @ignore
*/
oj.ArrayCellSet.prototype.getStartRow = function()
{
return this.m_startRow;
};
/**
* Gets the start column property for testing
* @return {number} the start column
* @export
* @ignore
*/
oj.ArrayCellSet.prototype.getStartColumn = function()
{
return this.m_startColumn;
};
Source: src/main/javascript/oracle/oj/ojdatagrid/ArrayCellSet.js
Oracle® JavaScript Extension Toolkit (JET)
1.1.2
E65298-01