Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PivotGrid - Column expands after datasource reload - T1246608 #28884

Open
wants to merge 6 commits into
base: 25_1
Choose a base branch
from

Conversation

Tucchhaa
Copy link
Contributor

@Tucchhaa Tucchhaa commented Feb 3, 2025

No description provided.

@Tucchhaa Tucchhaa requested a review from a team as a code owner February 3, 2025 05:18
@Tucchhaa Tucchhaa self-assigned this Feb 4, 2025
@Tucchhaa Tucchhaa force-pushed the T1246608_pivotgrid_header_resets_25_1 branch from ca2ca00 to 4f3d0bb Compare February 4, 2025 18:44
Comment on lines 1566 to 1570
loadOptions[expandedPathOptionName] = [[2010], [2010, 1]];
store.load(loadOptions).done(function() {
assert.deepEqual(actualFilter, [['date', '=', 2010]], 'rows count');
assert.deepEqual(actualFilter, ['date', '=', 2010], 'rows count');
});
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was to check if filter duplicates. Like [['date', '=', '2010'], 'or', ['date', '=', '2010']]. After my fix, the nesting structure is changed a little bit, but no duplicate filter occur, so that's ok

Comment on lines 1596 to 1599
store.load(loadOptions).done(function() {
assert.deepEqual(actualFilter, [[['date1', '=', 2010]], 'and', [['date2', '=', 2010]]], 'rows count');
assert.deepEqual(actualFilter, [['date1', '=', 2010], 'and', ['date2', '=', 2010]], 'rows count');
});
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -1740,7 +1740,7 @@ QUnit.module('Expanding items', moduleConfig, () => {
{ dataField: 'ShipRegion' },
{ dataField: 'ShipCity' }
],
rowExpandedPaths: [['USA', 'AK']],
rowExpandedPaths: [['USA'], ['USA', 'AK']],
Copy link
Contributor Author

@Tucchhaa Tucchhaa Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rowExpandedPaths: [['USA', 'AK']] is an impossible expanded path in pivotgrid. To open 'AK', you have to first open 'US', so the expandedPaths must be at least this: [['USA'], ['USA', 'AK']]

rows,
filters: filters.concat(getExpandedPathSliceFilter(options, 'columns', j, firstCollapsedColumnIndex)).concat(rowFilterByExpandedPaths),
filters: commonFilters,
Copy link
Contributor Author

@Tucchhaa Tucchhaa Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requestOptions.filters is an array of fields. getExpandedPathSliceFilter was extending fields with properties field.filterValues and 'field.filterType='include'. field.filterValues is an array of values of the field that we want to request. Later this array is transformed into a filter expression: https://github.com/DevExpress/DevExtreme/pull/28884/files#diff-b5d7b2b7d8a915d9d730cc006e8643b086ab02749e516b8cf9d46ec2dd1bd121L174

But now filters for fields are directly generated in the form of filter expression (aka [['field', '=', 'some value']]) and then just merged with options.filters: https://github.com/DevExpress/DevExtreme/pull/28884/files#diff-b5d7b2b7d8a915d9d730cc006e8643b086ab02749e516b8cf9d46ec2dd1bd121R205-R207

@Tucchhaa Tucchhaa force-pushed the T1246608_pivotgrid_header_resets_25_1 branch from 4f3d0bb to d2f7078 Compare February 5, 2025 06:51
@Tucchhaa Tucchhaa force-pushed the T1246608_pivotgrid_header_resets_25_1 branch from d2f7078 to b550e1e Compare February 5, 2025 09:11
return 0;
}

function getExpandedPathsFilterExprByLevel(options, axis, level) {
Copy link
Contributor Author

@Tucchhaa Tucchhaa Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function fixes the issue. Before getExpandedPathSliceFilter was used to calculate filters.

Now the algorithm for calculating filters is different. getExpandedPathSliceFilter was extending fields array, adding filterValues and filterType=include to it. filterValues was an array which contained values of the columns that were expanded.

E.g. given this expandedPaths: [[2017], [2017, 1], [2018], [2018, 2]]. The result for level=2 will be this:

[
   { dataField: 'Year', filterValues: [2017, 2018], filterType: 'include' }, 
   { dataField: 'Quarter', filterValues: [1, 2], filterType: 'include' }
  ]

Later these fields will be converted into this filter expression:

[
  [['Year', '=', '2017'], 'or', ['Year', '=', '2018]],
  'and', 
  [['Quarter', '=', 1], 'or', ['Quarter', '=', 2]]
 ]

The problem with the resulted filter expression is that the data for the Quarter 2 of 2017 will be loaded (it matches the filter).

The new function, getExpandedPathsFilterExprByLevel, uses different algorithm and the resulting filter expression for the same expandedPaths for level=2 will be:

[
   [['Year', '=', 1996], 'and', ['Month', '=', 1]],
    'or',
    [['Year', '=', 1997], 'and', ['Month', '=', 2]]
 ]

P.S. level is the level of nesting. PivotGrid has multi-level columns and rows. For each row level and column level a separate request is created.

@Tucchhaa Tucchhaa added the 25_1 label Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant