Skip to content

Commit

Permalink
WIP: Changed how getAtCell inside data source works #7031
Browse files Browse the repository at this point in the history
  • Loading branch information
wszymanski committed Jul 21, 2020
1 parent c0b1549 commit 411584e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
8 changes: 3 additions & 5 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ export default function Core(rootElement, userSettings, rootInstanceSymbol = fal
changes.push([
input[i][0],
prop,
dataSource.getAtCell(this.toPhysicalRow(input[i][0]), input[i][1]),
dataSource.getAtCell(this.toPhysicalRow(input[i][0]), prop),
input[i][2],
]);
}
Expand Down Expand Up @@ -2426,10 +2426,9 @@ export default function Core(rootElement, userSettings, rootInstanceSymbol = fal
*
* @memberof Core#
* @function getSourceDataAtCol
* @param {number} column Visual column index.
* @param {string|number} column Column property which may be also a physical column index.
* @returns {Array} Array of the column's cell values.
*/
// TODO: Getting data from `sourceData` should work always on physical indexes.
this.getSourceDataAtCol = function(column) {
return dataSource.getAtColumn(column);
};
Expand Down Expand Up @@ -2502,10 +2501,9 @@ export default function Core(rootElement, userSettings, rootInstanceSymbol = fal
* @memberof Core#
* @function getSourceDataAtCell
* @param {number} row Physical row index.
* @param {number} column Visual column index.
* @param {string|number} column Column property which may be also a physical column index.
* @returns {*} Cell data.
*/
// TODO: Getting data from `sourceData` should work always on physical indexes.
this.getSourceDataAtCell = function(row, column) {
return dataSource.getAtCell(row, column);
};
Expand Down
11 changes: 8 additions & 3 deletions src/dataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class DataSource {
/**
* Returns array of column values from the data source. `column` is the index of the row in the data source.
*
* @param {number} column Visual column index.
* @param {string|number} column Column property which may be also a physical column index.
* @returns {Array}
*/
getAtColumn(column) {
Expand Down Expand Up @@ -245,13 +245,18 @@ class DataSource {
* Returns a single value from the data.
*
* @param {number} row Physical row index.
* @param {number} column Visual column index.
* @param {number} column Column property which may be also a physical column index.
* @returns {*}
*/
getAtCell(row, column) {
const dataRow = this.modifyRowData(row);
let prop = column;

return this.getAtPhysicalCell(row, this.colToProp(column), dataRow);
if (Number.isInteger(column)) {
prop = this.colToProp(column);
}

return this.getAtPhysicalCell(row, prop, dataRow);
}

/**
Expand Down

0 comments on commit 411584e

Please sign in to comment.