diff --git a/packages/devextreme/js/__internal/grids/pivot_grid/data_source/m_data_source.ts b/packages/devextreme/js/__internal/grids/pivot_grid/data_source/m_data_source.ts index b5b1683bc03f..b5650b2327de 100644 --- a/packages/devextreme/js/__internal/grids/pivot_grid/data_source/m_data_source.ts +++ b/packages/devextreme/js/__internal/grids/pivot_grid/data_source/m_data_source.ts @@ -717,9 +717,9 @@ class PivotGridDataSource { values: this.getAreaFields('data'), filters: applyFilters ? this._fields.filter((f) => f !== field - && f.area - && f.filterValues - && f.filterValues.length) + && f.area + && f.filterValues + && f.filterValues.length) : [], skipValues: true, }; @@ -839,8 +839,8 @@ class PivotGridDataSource { } if (field.levels - && dimension !== descriptions.filters - && dimension !== descriptions.values) { + && dimension !== descriptions.filters + && dimension !== descriptions.values) { dimension.push.apply(dimension, field.levels); if (field.filterValues && field.filterValues.length) { descriptions.filters.push(field); @@ -1049,9 +1049,9 @@ class PivotGridDataSource { if (store) { extend(options, descriptions); options.columnExpandedPaths = options.columnExpandedPaths - || this.getExpandedPaths(this._data, options, 'columns', that._lastLoadOptions); + || this.getExpandedPaths(this._data, options, 'columns', that._lastLoadOptions); options.rowExpandedPaths = options.rowExpandedPaths - || this.getExpandedPaths(this._data, options, 'rows', that._lastLoadOptions); + || this.getExpandedPaths(this._data, options, 'rows', that._lastLoadOptions); if (paginate) { options.pageSize = this._pageSize; @@ -1076,7 +1076,7 @@ class PivotGridDataSource { storeLoadOptions = storeLoadOptions .filter((options) => !(options.rows.length && options.rowTake === 0) - && !(options.columns.length && options.columnTake === 0)); + && !(options.columns.length && options.columnTake === 0)); if (!storeLoadOptions.length) { that._update(deferred); @@ -1130,8 +1130,8 @@ class PivotGridDataSource { paginate() { return this._paginate - && this._store - && this._store.supportPaging(); + && this._store + && this._store.supportPaging(); } isEmpty() { @@ -1160,8 +1160,8 @@ class PivotGridDataSource { that._sort(descriptions, loadedData); !that.isEmpty() - && isRunningTotalUsed(dataFields) - && summaryUtils.applyRunningTotal(descriptions, loadedData); + && isRunningTotalUsed(dataFields) + && summaryUtils.applyRunningTotal(descriptions, loadedData); that._data = loadedData; deferred !== false && when(deferred).done(() => { @@ -1405,6 +1405,9 @@ class PivotGridDataSource { if (delayedLoadTask) { delayedLoadTask.abort(); } + + that._store?.dispose(); + this._isDisposed = true; } diff --git a/packages/devextreme/js/__internal/grids/pivot_grid/local_store/m_local_store.ts b/packages/devextreme/js/__internal/grids/pivot_grid/local_store/m_local_store.ts index 174166bf6091..089fcf6da4c0 100644 --- a/packages/devextreme/js/__internal/grids/pivot_grid/local_store/m_local_store.ts +++ b/packages/devextreme/js/__internal/grids/pivot_grid/local_store/m_local_store.ts @@ -2,7 +2,6 @@ import ArrayStore from '@js/common/data/array_store'; import { CustomStore } from '@js/common/data/custom_store'; import { DataSource } from '@js/common/data/data_source/data_source'; import dataQuery from '@js/common/data/query'; -// eslint-disable-next-line import/extensions import { aggregators } from '@js/common/data/utils'; import Class from '@js/core/class'; import { noop } from '@js/core/utils/common'; @@ -585,6 +584,10 @@ const LocalStore = Class.inherit((function () { return drillDownItems; }, + + dispose() { + this._dataSource?.dispose(); + }, }; })()).include(storeDrillDownMixin); diff --git a/packages/devextreme/js/__internal/grids/pivot_grid/remote_store/m_remote_store.ts b/packages/devextreme/js/__internal/grids/pivot_grid/remote_store/m_remote_store.ts index 3412120c14f2..2f9ea5648be5 100644 --- a/packages/devextreme/js/__internal/grids/pivot_grid/remote_store/m_remote_store.ts +++ b/packages/devextreme/js/__internal/grids/pivot_grid/remote_store/m_remote_store.ts @@ -662,6 +662,10 @@ class RemoteStore { }, }); } + + dispose() { + this._dataSource?.dispose(); + } } export default { RemoteStore }; diff --git a/packages/devextreme/js/__internal/grids/pivot_grid/xmla_store/m_xmla_store.ts b/packages/devextreme/js/__internal/grids/pivot_grid/xmla_store/m_xmla_store.ts index 42245f38de34..384eaee528dc 100644 --- a/packages/devextreme/js/__internal/grids/pivot_grid/xmla_store/m_xmla_store.ts +++ b/packages/devextreme/js/__internal/grids/pivot_grid/xmla_store/m_xmla_store.ts @@ -1159,6 +1159,9 @@ class XmlaStore { return true; } + dispose() { + } + getDrillDownItems(options, params) { // @ts-expect-error const result = new Deferred(); diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.pivotGrid/dataSource_bundled.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.pivotGrid/dataSource_bundled.tests.js index 2b4ad041c12d..0a6f30361ae4 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.pivotGrid/dataSource_bundled.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.pivotGrid/dataSource_bundled.tests.js @@ -6917,6 +6917,29 @@ QUnit.module('Stores', () => { }); }); + QUnit.test('PivotGridDataSource dispose disposes LocalStore', function(assert) { + const dataSource = new PivotGridDataSource({ + store: window.orders + }); + const store = dataSource.store(); + + dataSource.dispose(); + + assert.ok(store._dataSource._disposed, 'LocalStore internal DataSource is disposed'); + }); + + QUnit.test('PivotGridDataSource dispose disposes RemoteStore', function(assert) { + const dataSource = new PivotGridDataSource({ + remoteOperations: true, + store: window.orders + }); + const store = dataSource.store(); + + dataSource.dispose(); + + assert.ok(store._dataSource._disposed, 'RemoteStore internal DataSource is disposed'); + }); + });