Skip to content

Commit b0d546e

Browse files
MKirovaMKirova
authored andcommitted
Fix issue with 4th dimension missing values.
1 parent 7be654e commit b0d546e

File tree

2 files changed

+40
-16
lines changed

2 files changed

+40
-16
lines changed

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-util.ts

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ export class PivotUtil {
114114
data.splice(i, 1, ...dimData);
115115
i += dimData.length - 1;
116116
}
117+
} else {
118+
// this is leaf
119+
let leafDim = dim;
120+
let currLvl = currDimLvl;
121+
while (leafDim.childLevel) {
122+
leafDim = leafDim.childLevel;
123+
currLvl++;
124+
}
125+
rec[leafDim.memberName + '_' + pivotKeys.level] = currLvl;
126+
rec[field + '_' + pivotKeys.level] = undefined;
117127
}
118128
}
119129
return data;
@@ -227,21 +237,21 @@ export class PivotUtil {
227237
.getFieldsHierarchy(child[pivotKeys.records], [row], PivotDimensionType.Row, pivotKeys);
228238
const siblingData2 = PivotUtil
229239
.processHierarchy(hierarchyFields2, child ?? [], keys, 0);
230-
if (siblingData2.length === 1) {
231-
child[row.memberName] = sibling[row.memberName];
232-
// add children to current level if dimensions have same depth
233-
for (const sib of siblingData2) {
234-
if (sib[row.memberName + '_' + pivotKeys.records]) {
235-
child[row.memberName + '_' + pivotKeys.records] =
236-
child[row.memberName + '_' + pivotKeys.records]
240+
if (siblingData2.length === 1) {
241+
child[row.memberName] = sibling[row.memberName];
242+
// add children to current level if dimensions have same depth
243+
for (const sib of siblingData2) {
244+
if (sib[row.memberName + '_' + pivotKeys.records]) {
245+
child[row.memberName + '_' + pivotKeys.records] =
246+
child[row.memberName + '_' + pivotKeys.records]
237247
.concat(sib[row.memberName + '_' + pivotKeys.records]);
238-
child[row.memberName] = sib[row.memberName];
239-
}
248+
child[row.memberName] = sib[row.memberName];
240249
}
241-
} else {
242-
// otherwise overwrite direct child collection
243-
child[row.memberName + '_' + pivotKeys.records] = siblingData2;
244250
}
251+
} else {
252+
// otherwise overwrite direct child collection
253+
child[row.memberName + '_' + pivotKeys.records] = siblingData2;
254+
}
245255
PivotUtil.processSiblingProperties(child, siblingData2, keys);
246256
}
247257
if (prevRowDim.childLevel) {
@@ -270,6 +280,12 @@ export class PivotUtil {
270280
if (h[pivotKeys.children] && h[pivotKeys.children].size > 0) {
271281
const nestedData = this.processHierarchy(h[pivotKeys.children], rec,
272282
pivotKeys, level + 1, rootData);
283+
for (const nested of nestedData) {
284+
if (nested[pivotKeys.records] && nested[pivotKeys.records].length === 1) {
285+
// only 1 child record, apply same props to parent.
286+
PivotUtil.processSiblingProperties(nested[pivotKeys.records][0], [nested], pivotKeys);
287+
}
288+
}
273289
obj[pivotKeys.records] = this.getDirectLeafs(nestedData, pivotKeys);
274290
obj[field + '_' + pivotKeys.records] = nestedData;
275291
if (!rootData) {
@@ -298,10 +314,10 @@ export class PivotUtil {
298314
const parentFields = [];
299315
const field = currentDim.memberName;
300316
const value = rec[field];
301-
for(const prev of prevDims) {
317+
for (const prev of prevDims) {
302318
const dimData = PivotUtil.getDimensionLevel(prev, rec,
303-
{ aggregations: 'aggregations', records: 'records', children: 'children', level: 'level'});
304-
parentFields.push(rec[dimData.dimension.memberName]);
319+
{ aggregations: 'aggregations', records: 'records', children: 'children', level: 'level' });
320+
parentFields.push(rec[dimData.dimension.memberName]);
305321
}
306322
parentFields.push(value);
307323
return parentFields.join('_');

src/app/pivot-grid/pivot-grid.sample.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export class PivotGridSampleComponent {
3030
}
3131
],
3232
rows: [
33-
3433
new IgxPivotDateDimension(
3534
{
3635
memberName: 'Date',
@@ -53,6 +52,15 @@ export class PivotGridSampleComponent {
5352
memberName: 'ProductCategory',
5453
enabled: true
5554
}
55+
},
56+
{
57+
memberFunction: () => 'AllSel',
58+
memberName: 'AllSel',
59+
enabled: true,
60+
childLevel: {
61+
memberName: 'SellerName',
62+
enabled: true
63+
}
5664
}
5765
],
5866
values: [

0 commit comments

Comments
 (0)