Skip to content

Commit

Permalink
Get the sourceColumn working with totals correctly
Browse files Browse the repository at this point in the history
- Now it doesn't crash when you add aggregations
  • Loading branch information
mofojed committed Dec 5, 2023
1 parent 026b747 commit 82e7941
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
13 changes: 3 additions & 10 deletions packages/iris-grid/src/IrisGridTableModelTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1001,11 +1001,6 @@ class IrisGridTableModelTemplate<
* @param row Row index to get the source column from
*/
sourceColumn(column: ModelIndex, row: ModelIndex): Column {
const proxyCell = this.sourceForCell(column, row);
if (proxyCell.column !== column) {
return this.columns[proxyCell.column];
}

const totalsRow = this.totalsRow(row);
if (totalsRow != null) {
const operation = this.totals?.operationOrder[totalsRow];
Expand All @@ -1023,12 +1018,10 @@ class IrisGridTableModelTemplate<
this.totals?.operationOrder.length === 1) &&
col.name === tableColumn.name)
);
if (totalsColumn == null) {
throw new Error(
`Unable to find totals column for ${tableColumn.name} with operation ${operation}`
);
if (totalsColumn != null) {
return totalsColumn;
}
return totalsColumn;
// There may be cases were the totals table doesn't have a column, such as when there's a virtual column
}
return this.columns[column];
}
Expand Down
9 changes: 9 additions & 0 deletions packages/iris-grid/src/IrisGridTreeTableModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,15 @@ class IrisGridTreeTableModel extends IrisGridTableModelTemplate<
return { column: column + depth, row };
}

sourceColumn(column: ModelIndex, row: ModelIndex): Column {
if (column >= this.virtualColumns.length) {
return super.sourceColumn(column, row);
}

const depth = this.depthForRow(row);
return this.columns[column + depth];
}

getClearFilterRange(column: ModelIndex): BoundedAxisRange | null {
if (column >= this.virtualColumns.length) {
return super.getClearFilterRange(column);
Expand Down

0 comments on commit 82e7941

Please sign in to comment.