Skip to content

Commit 912b3f7

Browse files
PivotGrid - Expand icon is missing for parent-child OLAP hierarchies(T1283598) (#33593)
1 parent 160ed46 commit 912b3f7

2 files changed

Lines changed: 107 additions & 3 deletions

File tree

packages/devextreme/js/__internal/grids/pivot_grid/xmla_store/m_xmla_store.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,12 @@ class XmlaStore {
233233

234234
if (i < path.length) {
235235
if (isLastDimensionInGroup) {
236-
arg = `(${dataField}.${preparePathValue(path[i], dataField)})`;
236+
const pathValue = path[i];
237+
if (hierarchyName && isString(pathValue) && pathValue.startsWith(`${hierarchyName}.`)) {
238+
arg = `(${pathValue})`;
239+
} else {
240+
arg = `(${dataField}.${preparePathValue(pathValue, dataField)})`;
241+
}
237242
}
238243
} else if (i <= expandAllIndex) {
239244
if (i === 0 && expandAllCount === 0) {
@@ -529,7 +534,12 @@ class XmlaStore {
529534
|| dimension.hierarchyName !== options[headerName][index + 1]
530535
.hierarchyName
531536
) {
532-
slices.push(`${dimension.dataField}.${this.preparePathValue(value, dimension.dataField)}`);
537+
const { hierarchyName } = dimension;
538+
if (hierarchyName && isString(value) && value.startsWith(`${hierarchyName}.`)) {
539+
slices.push(value);
540+
} else {
541+
slices.push(`${dimension.dataField}.${this.preparePathValue(value, dimension.dataField)}`);
542+
}
533543
}
534544
});
535545
}
@@ -580,7 +590,12 @@ class XmlaStore {
580590
if (field.hierarchyName && (fields[index + 1] || {}).hierarchyName === field.hierarchyName) {
581591
return;
582592
}
583-
slice.push(`${field.dataField}.${this.preparePathValue(value, field.dataField)}`);
593+
const { hierarchyName } = field;
594+
if (hierarchyName && isString(value) && value.startsWith(`${hierarchyName}.`)) {
595+
slice.push(value);
596+
} else {
597+
slice.push(`${field.dataField}.${this.preparePathValue(value, field.dataField)}`);
598+
}
584599
});
585600
}
586601

packages/devextreme/testing/tests/DevExpress.ui.widgets.pivotGrid/store.xmla.tests.js

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,95 @@ QUnit.module('Hierarchies', stubsEnvironment, () => {
465465
assert.equal(query, 'with set [DX_columns] as NonEmpty({[Product].[Product Categories].[All],[Product].[Product Categories].[Category]}, {[Measures].[Customer Count]}) set [DX_rows] as NonEmpty({Descendants({[Ship Date].[Calendar].[Month].&[2003]&[8]}, [Ship Date].[Calendar].[Date], SELF_AND_BEFORE)}, {[Measures].[Customer Count]}) SELECT CrossJoin([DX_columns],{[Measures].[Customer Count]}) DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME, MEMBER_VALUE ON columns,[DX_rows] DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME, MEMBER_VALUE ON rows FROM [Adventure Works] CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR, FORE_COLOR, FONT_FLAGS');
466466
});
467467

468+
QUnit.test('T1283598. Hierarchy slice should not duplicate hierarchy prefix when path value is a full unique name', function(assert) {
469+
this.store.load({
470+
columns: [{ dataField: '[Active Month].[Active Month]' }],
471+
rows: [
472+
{ dataField: '[Product].[Product Purchaser Type].[Purchaser Type]', hierarchyName: '[Product].[Product Purchaser Type]' },
473+
{ dataField: '[Product].[Product Purchaser Type].[Purchaser Sub Type]', hierarchyName: '[Product].[Product Purchaser Type]' },
474+
{ dataField: '[Product].[Product Nbr]' }
475+
],
476+
values: [{ dataField: '[Measures].[Members]', caption: 'Members' }],
477+
headerName: 'rows',
478+
path: [
479+
'[Product].[Product Purchaser Type].[Purchaser Type].&[Commercial]',
480+
'[Product].[Product Purchaser Type].[Purchaser Type].&[Commercial].&[Group]'
481+
]
482+
});
483+
const query = this.getQuery();
484+
485+
assert.notStrictEqual(
486+
query.indexOf('WHERE ([Product].[Product Purchaser Type].[Purchaser Type].&[Commercial].&[Group])'),
487+
-1,
488+
'WHERE slice contains the full unique name once'
489+
);
490+
assert.strictEqual(
491+
query.indexOf('[Product].[Product Purchaser Type].[Purchaser Sub Type].[Product].[Product Purchaser Type]'),
492+
-1,
493+
'WHERE slice does not duplicate the hierarchy prefix'
494+
);
495+
});
496+
497+
QUnit.test('T1283598. Axis SET should not duplicate hierarchy prefix when expanded path value is a full unique name', function(assert) {
498+
this.store.load({
499+
columns: [{ dataField: '[Active Month].[Active Month]' }],
500+
rows: [
501+
{ dataField: '[Product].[Product Purchaser Type].[Purchaser Type]', hierarchyName: '[Product].[Product Purchaser Type]' },
502+
{ dataField: '[Product].[Product Purchaser Type].[Purchaser Sub Type]', hierarchyName: '[Product].[Product Purchaser Type]' },
503+
{ dataField: '[Product].[Product Nbr]' }
504+
],
505+
values: [{ dataField: '[Measures].[Members]', caption: 'Members' }],
506+
rowExpandedPaths: [
507+
['[Product].[Product Purchaser Type].[Purchaser Type].&[Commercial]'],
508+
['[Product].[Product Purchaser Type].[Purchaser Type].&[Commercial]', '[Product].[Product Purchaser Type].[Purchaser Type].&[Commercial].&[Group]']
509+
]
510+
});
511+
const query = this.getQuery();
512+
513+
assert.notStrictEqual(
514+
query.indexOf('([Product].[Product Purchaser Type].[Purchaser Type].&[Commercial].&[Group])'),
515+
-1,
516+
'axis SET contains the full unique name once'
517+
);
518+
assert.strictEqual(
519+
query.indexOf('[Product].[Product Purchaser Type].[Purchaser Sub Type].[Product].[Product Purchaser Type]'),
520+
-1,
521+
'axis SET does not duplicate the hierarchy prefix'
522+
);
523+
});
524+
525+
QUnit.test('T1283598. Drill-down WHERE slice should not duplicate hierarchy prefix when path value is a full unique name', function(assert) {
526+
this.store.getDrillDownItems({
527+
columns: [{ dataField: '[Active Month].[Active Month]' }],
528+
rows: [
529+
{ dataField: '[Product].[Product Purchaser Type].[Purchaser Type]', hierarchyName: '[Product].[Product Purchaser Type]' },
530+
{ dataField: '[Product].[Product Purchaser Type].[Purchaser Sub Type]', hierarchyName: '[Product].[Product Purchaser Type]' },
531+
{ dataField: '[Product].[Product Nbr]' }
532+
],
533+
values: [{ dataField: '[Measures].[Members]', caption: 'Members' }]
534+
}, {
535+
columnPath: [],
536+
rowPath: [
537+
'[Product].[Product Purchaser Type].[Purchaser Type].&[Commercial]',
538+
'[Product].[Product Purchaser Type].[Purchaser Type].&[Commercial].&[Group]'
539+
],
540+
dataIndex: 0,
541+
maxRowCount: 100
542+
});
543+
const query = this.getQuery();
544+
545+
assert.notStrictEqual(
546+
query.indexOf('WHERE ([Product].[Product Purchaser Type].[Purchaser Type].&[Commercial].&[Group])'),
547+
-1,
548+
'drill-down WHERE slice contains the full unique name once'
549+
);
550+
assert.strictEqual(
551+
query.indexOf('[Product].[Product Purchaser Type].[Purchaser Sub Type].[Product].[Product Purchaser Type]'),
552+
-1,
553+
'drill-down WHERE slice does not duplicate the hierarchy prefix'
554+
);
555+
});
556+
468557
QUnit.test('Hierarchy. Expand child when opposite axis expanded on several levels', function(assert) {
469558
this.store.load({
470559
columns: [{

0 commit comments

Comments
 (0)