Skip to content

Commit 4953082

Browse files
authored
T1234905: PivotGrid - Grand total row is shown when dataFieldArea is set to 'row' even if showGrandTotals is disabled (DevExpress#29058)
1 parent 8a915f9 commit 4953082

File tree

2 files changed

+135
-79
lines changed

2 files changed

+135
-79
lines changed

packages/devextreme/js/__internal/grids/pivot_grid/data_controller/m_data_controller.ts

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,39 +1091,34 @@ const DataController = Class.inherit((function () {
10911091
? hiddenGrandTotals.length !== dataFields.length
10921092
: true;
10931093

1094-
const rowOptions: any = {
1095-
isEmptyGrandTotal: data.isEmptyGrandTotalRow,
1094+
const commonOptions: any = {
10961095
texts: options.texts || {},
10971096
hiddenTotals,
10981097
hiddenValues,
1099-
hiddenGrandTotals: [],
1098+
hiddenGrandTotals,
1099+
showEmpty: !options.hideEmptySummaryCells,
1100+
dataFields,
1101+
progress: 0,
1102+
};
1103+
const rowOptions: any = extend({}, commonOptions, {
1104+
isEmptyGrandTotal: data.isEmptyGrandTotalRow,
11001105
showTotals: options.showRowTotals,
1106+
showTotalsPrior: options.showTotalsPrior === 'rows' || options.showTotalsPrior === 'both',
11011107
showGrandTotals: options.showRowGrandTotals !== false
1102-
&& grandTotalsAreHiddenForNotAllDataFields,
1108+
&& grandTotalsAreHiddenForNotAllDataFields,
11031109
sortBySummaryPaths: createSortPaths(columnFields, dataFields),
1104-
showTotalsPrior: options.showTotalsPrior === 'rows' || options.showTotalsPrior === 'both',
1105-
showEmpty: !options.hideEmptySummaryCells,
11061110
layout: options.rowHeaderLayout,
11071111
fields: rowFields,
1108-
dataFields,
1109-
progress: 0,
1110-
};
1111-
const columnOptions: any = {
1112+
});
1113+
const columnOptions: any = extend({}, commonOptions, {
11121114
isEmptyGrandTotal: data.isEmptyGrandTotalColumn,
1113-
texts: options.texts || {},
1114-
hiddenTotals,
1115-
hiddenValues,
1116-
hiddenGrandTotals,
11171115
showTotals: options.showColumnTotals,
11181116
showTotalsPrior: options.showTotalsPrior === 'columns' || options.showTotalsPrior === 'both',
11191117
showGrandTotals: options.showColumnGrandTotals !== false
1120-
&& grandTotalsAreHiddenForNotAllDataFields,
1118+
&& grandTotalsAreHiddenForNotAllDataFields,
11211119
sortBySummaryPaths: createSortPaths(rowFields, dataFields),
1122-
showEmpty: !options.hideEmptySummaryCells,
11231120
fields: columnFields,
1124-
dataFields,
1125-
progress: 0,
1126-
};
1121+
});
11271122

11281123
const notifyProgress = function (progress) {
11291124
// - @ts-expect-error

packages/devextreme/testing/tests/DevExpress.ui.widgets.pivotGrid/dataController.tests.js

Lines changed: 121 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,46 @@ QUnit.module('dxPivotGrid DataController', moduleConfig, () => {
621621
]], 'Columns Info');
622622
});
623623

624-
QUnit.test('columnsInfo and rowsInfo without dimension fields when showGrandTotals is disabled on dataField level only for one field.', function(assert) {
624+
QUnit.test('dataFieldArea: column, hasDimensionFields: true; columnsInfo and rowsInfo when showGrandTotals is disabled only for one field', function(assert) {
625+
const dataController = new DataController({
626+
dataSource: {
627+
fields: [
628+
{ area: 'column' }, { area: 'row' },
629+
{ dataField: 'sum', caption: 'Sum', format: 'fixedPoint', area: 'data', showGrandTotals: false },
630+
{ dataField: 'avg', caption: 'Avg', format: 'fixedPoint', area: 'data' }
631+
],
632+
columns: [{ value: 'column 1' }],
633+
rows: [{ value: 'row 1' }]
634+
},
635+
texts: texts,
636+
dataFieldArea: 'column'
637+
});
638+
639+
assert.deepEqual(
640+
dataController.getColumnsInfo(),
641+
[[
642+
{ type: 'D', text: 'column 1', path: [ 'column 1' ], colspan: 2 },
643+
{ type: 'GT', text: 'Grand Total', }
644+
],
645+
[
646+
{ type: 'D', text: 'Sum', path: ['column 1'], dataIndex: 0, isLast: true },
647+
{ type: 'D', text: 'Avg', path: ['column 1'], dataIndex: 1, isLast: true },
648+
{ type: 'GT', text: 'Avg', dataIndex: 1, isLast: true }
649+
]],
650+
'Columns Info'
651+
);
652+
653+
assert.deepEqual(
654+
dataController.getRowsInfo(),
655+
[
656+
[{ type: 'D', text: 'row 1', path: ['row 1'], isLast: true }],
657+
[{ type: 'GT', text: 'Grand Total', isLast: true }]
658+
],
659+
'Rows Info'
660+
);
661+
});
662+
663+
QUnit.test('dataFieldArea: column, hasDimensionFields: false; columnsInfo and rowsInfo when showGrandTotals is disabled only for one field', function(assert) {
625664
const dataController = new DataController({
626665
dataSource: {
627666
fields: [
@@ -631,51 +670,70 @@ QUnit.module('dxPivotGrid DataController', moduleConfig, () => {
631670
columns: [],
632671
rows: []
633672
},
634-
texts: texts
673+
texts: texts,
674+
dataFieldArea: 'column'
635675
});
636676

637-
assert.deepEqual(dataController.getColumnsInfo(), [[
638-
{
639-
text: 'Grand Total',
640-
type: 'GT'
641-
}],
642-
643-
[{
644-
dataIndex: 1,
645-
isLast: true,
646-
text: 'Avg',
647-
type: 'GT'
648-
}]], 'Columns Info');
677+
assert.deepEqual(
678+
dataController.getColumnsInfo(),
679+
[
680+
[{ type: 'GT', text: 'Grand Total', }],
681+
[{ type: 'GT', text: 'Avg', dataIndex: 1, isLast: true }]
682+
],
683+
'Columns Info'
684+
);
649685

650-
assert.deepEqual(dataController.getRowsInfo(), [[
651-
{
652-
isLast: true,
653-
text: 'Grand Total',
654-
type: 'GT'
655-
}
656-
]], 'Rows Info');
686+
assert.deepEqual(
687+
dataController.getRowsInfo(),
688+
[
689+
[{ type: 'GT', text: 'Grand Total', isLast: true, }]
690+
],
691+
'Rows Info'
692+
);
657693
});
658694

659-
QUnit.test('T541266. No dublicate cells in Chrome 60', function(assert) {
695+
QUnit.test('dataFieldArea: row, hasDimensionFields: true; columnsInfo and rowsInfo when showGrandTotals is disabled only for one field', function(assert) {
660696
const dataController = new DataController({
661697
dataSource: {
662698
fields: [
663-
{ area: 'row' },
664-
{ area: 'row' },
665-
{ area: 'data', caption: 'Sum', format: 'fixedPoint' }
699+
{ area: 'column' }, { area: 'row' },
700+
{ dataField: 'sum', caption: 'Sum', format: 'fixedPoint', area: 'data', showGrandTotals: false },
701+
{ dataField: 'avg', caption: 'Avg', format: 'fixedPoint', area: 'data' }
666702
],
667-
rows: [{ 'value': 2014, 'index': 1, 'text': '2014', 'children': [{ 'value': 1, 'index': 10, 'text': 'Q1' }, { 'value': 2, 'index': 11, 'text': 'Q2' }, { 'value': 3, 'index': 12, 'text': 'Q3' }, { 'value': 4, 'index': 13, 'text': 'Q4' }] }, { 'value': 2015, 'index': 2, 'text': '2015', 'children': [{ 'value': 1, 'index': 4, 'text': 'Q1', 'children': [{ 'value': 1, 'index': 6, 'text': 'January' }, { 'value': 2, 'index': 7, 'text': 'February' }, { 'value': 3, 'index': 8, 'text': 'March' }] }] }]
703+
columns: [{ value: 'column 1' }],
704+
rows: [{ value: 'row 1' }]
668705
},
669-
texts: texts
706+
texts: texts,
707+
dataFieldArea: 'row'
670708
});
671709

672-
const rowsInfo = dataController.getRowsInfo(true);
673-
674-
assert.equal(rowsInfo[0].length, 2);
675-
assert.equal(rowsInfo[5].length, 3);
710+
assert.deepEqual(
711+
dataController.getColumnsInfo(),
712+
[[
713+
{ type: 'D', text: 'column 1', path: ['column 1'], isLast: true },
714+
{ type: 'GT', text: 'Grand Total', isLast: true }
715+
]],
716+
'Columns Info'
717+
);
718+
719+
assert.deepEqual(
720+
dataController.getRowsInfo(),
721+
[[
722+
{ type: 'D', text: 'row 1', path: ['row 1'], rowspan: 2 },
723+
{ type: 'D', text: 'Sum', path: ['row 1'], dataIndex: 0, isLast: true }
724+
],
725+
[
726+
{ type: 'D', text: 'Avg', path: ['row 1'], dataIndex: 1, isLast: true }
727+
],
728+
[
729+
{ type: 'GT', text: 'Grand Total' },
730+
{ type: 'GT', text: 'Avg', dataIndex: 1, isLast: true }
731+
]],
732+
'Rows Info'
733+
);
676734
});
677735

678-
QUnit.test('columnsInfo and rowsInfo without dimension fields when showGrandTotals is disabled on dataField level only for one field and dataFieldArea = row', function(assert) {
736+
QUnit.test('dataFieldArea: row, hasDimensionFields: false; columnsInfo and rowsInfo when showGrandTotals is disabled only for one field', function(assert) {
679737
const dataController = new DataController({
680738
dataSource: {
681739
fields: [
@@ -689,38 +747,41 @@ QUnit.module('dxPivotGrid DataController', moduleConfig, () => {
689747
dataFieldArea: 'row'
690748
});
691749

692-
assert.deepEqual(dataController.getRowsInfo(), [
750+
assert.deepEqual(
751+
dataController.getColumnsInfo(),
693752
[
694-
{
695-
text: 'Grand Total',
696-
type: 'GT',
697-
rowspan: 2
698-
},
699-
{
700-
dataIndex: 0,
701-
isLast: true,
702-
text: 'Sum',
703-
type: 'GT'
704-
},
753+
[{ type: 'GT', text: 'Grand Total', isLast: true }]
705754
],
706-
[
707-
{
708-
dataIndex: 1,
709-
isLast: true,
710-
text: 'Avg',
711-
type: 'GT'
712-
}
755+
'Columns Info'
756+
);
713757

714-
]
715-
], 'Rows Info');
758+
assert.deepEqual(
759+
dataController.getRowsInfo(),
760+
[[
761+
{ type: 'GT', text: 'Grand Total', },
762+
{ type: 'GT', text: 'Avg', dataIndex: 1, isLast: true }
763+
]],
764+
'Rows Info'
765+
);
766+
});
716767

717-
assert.deepEqual(dataController.getColumnsInfo(), [[
718-
{
719-
isLast: true,
720-
text: 'Grand Total',
721-
type: 'GT'
722-
}
723-
]], 'Columns Info');
768+
QUnit.test('T541266. No dublicate cells in Chrome 60', function(assert) {
769+
const dataController = new DataController({
770+
dataSource: {
771+
fields: [
772+
{ area: 'row' },
773+
{ area: 'row' },
774+
{ area: 'data', caption: 'Sum', format: 'fixedPoint' }
775+
],
776+
rows: [{ 'value': 2014, 'index': 1, 'text': '2014', 'children': [{ 'value': 1, 'index': 10, 'text': 'Q1' }, { 'value': 2, 'index': 11, 'text': 'Q2' }, { 'value': 3, 'index': 12, 'text': 'Q3' }, { 'value': 4, 'index': 13, 'text': 'Q4' }] }, { 'value': 2015, 'index': 2, 'text': '2015', 'children': [{ 'value': 1, 'index': 4, 'text': 'Q1', 'children': [{ 'value': 1, 'index': 6, 'text': 'January' }, { 'value': 2, 'index': 7, 'text': 'February' }, { 'value': 3, 'index': 8, 'text': 'March' }] }] }]
777+
},
778+
texts: texts
779+
});
780+
781+
const rowsInfo = dataController.getRowsInfo(true);
782+
783+
assert.equal(rowsInfo[0].length, 2);
784+
assert.equal(rowsInfo[5].length, 3);
724785
});
725786

726787
// B234872

0 commit comments

Comments
 (0)