From ec7e1ce7be75824febb2324247acf6c17b88687d Mon Sep 17 00:00:00 2001 From: Luke Cotter <4013877+lukecotter@users.noreply.github.com> Date: Wed, 29 Apr 2026 15:14:38 +0100 Subject: [PATCH 1/2] fix: correct data push in rowsToData for data tree child rows --- src/js/modules/ColumnCalcs/ColumnCalcs.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/modules/ColumnCalcs/ColumnCalcs.js b/src/js/modules/ColumnCalcs/ColumnCalcs.js index 2d706004b..d745dc070 100644 --- a/src/js/modules/ColumnCalcs/ColumnCalcs.js +++ b/src/js/modules/ColumnCalcs/ColumnCalcs.js @@ -411,7 +411,7 @@ export default class ColumnCalcs extends Module{ if(hasDataTreeColumnCalcs && row.modules.dataTree?.open){ this.rowsToData(dataTree.getFilteredTreeChildren(row)).forEach(dataRow =>{ - data.push(row); + data.push(dataRow); }); } }); @@ -583,4 +583,4 @@ export default class ColumnCalcs extends Module{ } } } -} \ No newline at end of file +} From eee9315a3b4c6f9dbcb78a6f21e5728aa7ce739b Mon Sep 17 00:00:00 2001 From: Luke Cotter <4013877+lukecotter@users.noreply.github.com> Date: Wed, 29 Apr 2026 15:28:20 +0100 Subject: [PATCH 2/2] test: add rowsToData test for data tree child rows inclusion --- test/unit/modules/ColumnCalcs.spec.js | 41 ++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/test/unit/modules/ColumnCalcs.spec.js b/test/unit/modules/ColumnCalcs.spec.js index 6ef0132cc..621cd7440 100644 --- a/test/unit/modules/ColumnCalcs.spec.js +++ b/test/unit/modules/ColumnCalcs.spec.js @@ -147,6 +147,45 @@ describe('ColumnCalcs', function(){ expect(data[1].name).toBe("Jane"); }); + test('rowsToData includes data tree child row data when child calcs are enabled', function(){ + const childRows = [ + {getData: function() { return {id: 2, value: 20}; }, modules: {}}, + {getData: function() { return {id: 3, value: 30}; }, modules: {}}, + ]; + const parentRow = { + getData: function() { return {id: 1, value: 10}; }, + modules: { + dataTree: { + open: true, + }, + }, + }; + + const mockThis = { + rowsToData: ColumnCalcs.prototype.rowsToData, + table: { + options: { + dataTree: true, + dataTreeChildColumnCalcs: true, + }, + modules: { + dataTree: { + getFilteredTreeChildren: jest.fn(() => childRows), + }, + }, + }, + }; + + const data = ColumnCalcs.prototype.rowsToData.call(mockThis, [parentRow]); + + expect(data).toEqual([ + {id: 1, value: 10}, + {id: 2, value: 20}, + {id: 3, value: 30}, + ]); + expect(mockThis.table.modules.dataTree.getFilteredTreeChildren).toHaveBeenCalledWith(parentRow); + }); + test('generateRowData creates calculation results', function(){ // Create mock data const data = [ @@ -266,4 +305,4 @@ describe('ColumnCalcs', function(){ afterAll(() => { Module.prototype.registerTableOption = originalRegisterTableOption; Module.prototype.registerColumnOption = originalRegisterColumnOption; -}); \ No newline at end of file +});